Spaces:
Sleeping
Sleeping
colab-user commited on
Commit ·
8aed760
1
Parent(s): d8c95b8
fix cls transciption
Browse files34 unmodified lines35363738394041424344454647484950515253545556575859606162636465666768697071727374757638 unmodified lines11511611711811912012134 unmodified linesclass TranscriptionService:"""Service for speech-to-text transcription using faster-whisper.Implements singleton pattern for model caching.Returns word-level timestamps for precision speaker alignment."""_instance: Optional["TranscriptionService"] = None_model: Optional[WhisperModel] = Nonedef __new__(cls):if cls._instance is None:cls._instance = super().__new__(cls)return cls._instance@classmethoddef get_model(cls) -> WhisperModel:"""Get or load the Whisper model (lazy loading with caching).Returns:Loaded WhisperModel instance"""if cls._model is None:logger.debug(f"Loading Whisper model: {settings.whisper_model}")logger.debug(f"Device: {settings.resolved_device}, Compute type: {settings.resolved_compute_type}")cls._model = WhisperModel(settings.whisper_model,device=settings.resolved_device,compute_type=settings.resolved_compute_type,download_root=None, # Use default HF cache)logger.debug("Whisper model loaded successfully")return cls._model@classmethoddef is_loaded(cls) -> bool:38 unmodified lines"""Transcribe audio and return word-level timestamps."""model = cls.get_model(model_name)if vad_options is None or vad_options is False:use_vad = False34 unmodified lines3536373839404142434445464748495051525354555657585938 unmodified lines989910010110210310434 unmodified linesclass TranscriptionService:_models: Dict[str, WhisperModel] = {}@classmethoddef get_model(cls, model_name: Optional[str] = None) -> WhisperModel:model_name = model_name or settings.whisper_modelif model_name not in cls._models:logger.debug(f"Loading Whisper model: {model_name}")logger.debug(f"Device: {settings.resolved_device}, Compute type: {settings.resolved_compute_type}")cls._models[model_name] = WhisperModel(model_name,device=settings.resolved_device,compute_type=settings.resolved_compute_type,)logger.debug("Whisper model loaded successfully")return cls._models[model_name]@classmethoddef is_loaded(cls) -> bool:38 unmodified lines"""Transcribe audio and return word-level timestamps."""model = cls.get_model()if vad_options is None or vad_options is False:use_vad = False
app/services/transcription.py+13-30