o �J�h�@s�ddlmZddlZddlZddlmZmZmZmZm Z m Z ddl m Z ddl mZddlmZddlmZddlTdd lmZe�ZGd d �d �ZdS) �)�OptionalN)�FASTER_WHISPER_MODELS_DIR�DIARIZATION_MODELS_DIR� OUTPUT_DIR� INSANELY_FAST_WHISPER_MODELS_DIR�WHISPER_MODELS_DIR�UVR_MODELS_DIR)�FasterWhisperInference)�WhisperInference)�InsanelyFastWhisperInference)�BaseTranscriptionPipeline)�*)� get_loggerc@sHeZdZeeeeeee fde de de de de de de dd fd d ��Z d S) �WhisperFactory� whisper_type�whisper_model_dir�faster_whisper_model_dir�insanely_fast_whisper_model_dir�diarization_model_dir� uvr_model_dir� output_dir�returnr cCs�dtjd<|����}|tjjkr+tj� �r#t � d�t ||||d�St ||||d�S|tjjkr9t||||d�S|tjjkrGt ||||d�St ||||d�S)a� Create a whisper inference class based on the provided whisper_type. Parameters ---------- whisper_type : str The type of Whisper implementation to use. Supported values (case-insensitive): - "faster-whisper": https://github.com/openai/whisper - "whisper": https://github.com/openai/whisper - "insanely-fast-whisper": https://github.com/Vaibhavs10/insanely-fast-whisper whisper_model_dir : str Directory path for the Whisper model. faster_whisper_model_dir : str Directory path for the Faster Whisper model. insanely_fast_whisper_model_dir : str Directory path for the Insanely Fast Whisper model. diarization_model_dir : str Directory path for the diarization model. uvr_model_dir : str Directory path for the UVR model. output_dir : str Directory path where output files will be saved. Returns ------- BaseTranscriptionPipeline An instance of the appropriate whisper inference class based on the whisper_type. �TrueZKMP_DUPLICATE_LIB_OKzrXPU is detected but faster-whisper only supports CUDA. Automatically switching to insanely-whisper implementation.)� model_dirrrr)�os�environ�strip�lower� WhisperImpl�FASTER_WHISPER�value�torchZxpu� is_available�logger�warningr r ZWHISPERr ZINSANELY_FAST_WHISPER)rrrrrrr�r%�GC:\pinokio\api\whisper-webui.git\app\modules\whisper\whisper_factory.py�create_whisper_inferencesJ '    �� � ��z'WhisperFactory.create_whisper_inferenceN) �__name__� __module__� __qualname__� staticmethodrrrrrr�strr'r%r%r%r&rs2���������r)�typingrrr!�modules.utils.pathsrrrrrrZ(modules.whisper.faster_whisper_inferencer Z!modules.whisper.whisper_Inferencer Z/modules.whisper.insanely_fast_whisper_inferencer Z+modules.whisper.base_transcription_pipeliner �modules.whisper.data_classes�modules.utils.loggerrr#rr%r%r%r&�<module>s       
Memory