|
16 | 16 |
|
17 | 17 | from summary.core.analytics import MetadataManager, get_analytics |
18 | 18 | from summary.core.config import get_settings |
19 | | -from summary.core.file_service import FileService |
| 19 | +from summary.core.file_service import FileService, FileServiceException |
20 | 20 | from summary.core.llm_service import LLMException, LLMObservability, LLMService |
21 | 21 | from summary.core.prompt import ( |
22 | 22 | FORMAT_NEXT_STEPS, |
@@ -145,36 +145,41 @@ def process_audio_transcribe_summarize_v2( |
145 | 145 | max_retries=settings.whisperx_max_retries, |
146 | 146 | ) |
147 | 147 |
|
148 | | - with ( |
149 | | - file_service.prepare_audio_file(filename) as (audio_file, metadata), |
150 | | - ): |
151 | | - metadata_manager.track(task_id, {"audio_length": metadata["duration"]}) |
152 | | - |
153 | | - if language is None: |
154 | | - language = settings.whisperx_default_language |
155 | | - logger.info( |
156 | | - "No language specified, using default from settings: %s", |
157 | | - (language or "auto-detect"), |
158 | | - ) |
159 | | - else: |
160 | | - logger.info( |
161 | | - "Querying transcription in '%s' language", |
162 | | - language, |
| 148 | + try: |
| 149 | + with ( |
| 150 | + file_service.prepare_audio_file(filename) as (audio_file, metadata), |
| 151 | + ): |
| 152 | + metadata_manager.track(task_id, {"audio_length": metadata["duration"]}) |
| 153 | + |
| 154 | + if language is None: |
| 155 | + language = settings.whisperx_default_language |
| 156 | + logger.info( |
| 157 | + "No language specified, using default from settings: %s", |
| 158 | + (language or "auto-detect"), |
| 159 | + ) |
| 160 | + else: |
| 161 | + logger.info( |
| 162 | + "Querying transcription in '%s' language", |
| 163 | + language, |
| 164 | + ) |
| 165 | + |
| 166 | + transcription_start_time = time.time() |
| 167 | + |
| 168 | + transcription = whisperx_client.audio.transcriptions.create( |
| 169 | + model=settings.whisperx_asr_model, file=audio_file, language=language |
163 | 170 | ) |
164 | 171 |
|
165 | | - transcription_start_time = time.time() |
166 | | - |
167 | | - transcription = whisperx_client.audio.transcriptions.create( |
168 | | - model=settings.whisperx_asr_model, file=audio_file, language=language |
169 | | - ) |
| 172 | + transcription_time = round(time.time() - transcription_start_time, 2) |
| 173 | + metadata_manager.track( |
| 174 | + task_id, |
| 175 | + {"transcription_time": transcription_time}, |
| 176 | + ) |
| 177 | + logger.info("Transcription received in %.2f seconds.", transcription_time) |
| 178 | + logger.debug("Transcription: \n %s", transcription) |
170 | 179 |
|
171 | | - transcription_time = round(time.time() - transcription_start_time, 2) |
172 | | - metadata_manager.track( |
173 | | - task_id, |
174 | | - {"transcription_time": transcription_time}, |
175 | | - ) |
176 | | - logger.info("Transcription received in %.2f seconds.", transcription_time) |
177 | | - logger.debug("Transcription: \n %s", transcription) |
| 180 | + except FileServiceException: |
| 181 | + logger.exception("Unexpected error for filename: %s", filename) |
| 182 | + return |
178 | 183 |
|
179 | 184 | metadata_manager.track_transcription_metadata(task_id, transcription) |
180 | 185 |
|
|
0 commit comments