Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -191,6 +191,9 @@ def transcribe_audio(input_source, pipeline_type, model_id, dtype, batch_size, d
|
|
191 |
logging.info(f"Transcription parameters: pipeline_type={pipeline_type}, model_id={model_id}, dtype={dtype}, batch_size={batch_size}, download_method={download_method}")
|
192 |
verbose_messages = f"Starting transcription with parameters:\nPipeline Type: {pipeline_type}\nModel ID: {model_id}\nData Type: {dtype}\nBatch Size: {batch_size}\nDownload Method: {download_method}\n"
|
193 |
|
|
|
|
|
|
|
194 |
if pipeline_type == "faster-batched":
|
195 |
model = WhisperModel(model_id, device="auto", compute_type=dtype)
|
196 |
pipeline = BatchedInferencePipeline(model=model)
|
@@ -221,7 +224,10 @@ def transcribe_audio(input_source, pipeline_type, model_id, dtype, batch_size, d
|
|
221 |
if isinstance(input_source, str) and (input_source.startswith('http://') or input_source.startswith('https://')):
|
222 |
audio_path = download_audio(input_source, download_method)
|
223 |
verbose_messages += f"Audio file downloaded: {audio_path}\n"
|
224 |
-
if
|
|
|
|
|
|
|
225 |
yield f"Error: {audio_path}", "", None
|
226 |
return
|
227 |
else:
|
@@ -231,6 +237,8 @@ def transcribe_audio(input_source, pipeline_type, model_id, dtype, batch_size, d
|
|
231 |
trimmed_audio_path = trim_audio(audio_path, start_time or 0, end_time)
|
232 |
audio_path = trimmed_audio_path
|
233 |
verbose_messages += f"Audio trimmed from {start_time} to {end_time}\n"
|
|
|
|
|
234 |
|
235 |
start_time_perf = time.time()
|
236 |
if pipeline_type in ["faster-batched", "faster-sequenced"]:
|
@@ -285,8 +293,13 @@ def transcribe_audio(input_source, pipeline_type, model_id, dtype, batch_size, d
|
|
285 |
def update_model_dropdown(pipeline_type):
|
286 |
model_choices = get_model_options(pipeline_type)
|
287 |
logging.info(f"Model choices for {pipeline_type}: {model_choices}")
|
288 |
-
return gr.Dropdown.update(choices=model_choices, value=model_choices[0] if model_choices else None)
|
289 |
|
|
|
|
|
|
|
|
|
|
|
|
|
290 |
with gr.Blocks() as iface:
|
291 |
gr.Markdown("# Multi-Pipeline Transcription")
|
292 |
gr.Markdown("Transcribe audio using multiple pipelines and models.")
|
|
|
191 |
logging.info(f"Transcription parameters: pipeline_type={pipeline_type}, model_id={model_id}, dtype={dtype}, batch_size={batch_size}, download_method={download_method}")
|
192 |
verbose_messages = f"Starting transcription with parameters:\nPipeline Type: {pipeline_type}\nModel ID: {model_id}\nData Type: {dtype}\nBatch Size: {batch_size}\nDownload Method: {download_method}\n"
|
193 |
|
194 |
+
if verbose:
|
195 |
+
yield verbose_messages, "", None
|
196 |
+
|
197 |
if pipeline_type == "faster-batched":
|
198 |
model = WhisperModel(model_id, device="auto", compute_type=dtype)
|
199 |
pipeline = BatchedInferencePipeline(model=model)
|
|
|
224 |
if isinstance(input_source, str) and (input_source.startswith('http://') or input_source.startswith('https://')):
|
225 |
audio_path = download_audio(input_source, download_method)
|
226 |
verbose_messages += f"Audio file downloaded: {audio_path}\n"
|
227 |
+
if verbose:
|
228 |
+
yield verbose_messages, "", None
|
229 |
+
|
230 |
+
if not audio_path or audio_path.startswith("Error"):
|
231 |
yield f"Error: {audio_path}", "", None
|
232 |
return
|
233 |
else:
|
|
|
237 |
trimmed_audio_path = trim_audio(audio_path, start_time or 0, end_time)
|
238 |
audio_path = trimmed_audio_path
|
239 |
verbose_messages += f"Audio trimmed from {start_time} to {end_time}\n"
|
240 |
+
if verbose:
|
241 |
+
yield verbose_messages, "", None
|
242 |
|
243 |
start_time_perf = time.time()
|
244 |
if pipeline_type in ["faster-batched", "faster-sequenced"]:
|
|
|
293 |
def update_model_dropdown(pipeline_type):
|
294 |
model_choices = get_model_options(pipeline_type)
|
295 |
logging.info(f"Model choices for {pipeline_type}: {model_choices}")
|
|
|
296 |
|
297 |
+
# Check if there are model choices available before setting the value
|
298 |
+
if model_choices:
|
299 |
+
return gr.Dropdown.update(choices=model_choices, value=model_choices[0])
|
300 |
+
else:
|
301 |
+
return gr.Dropdown.update(choices=[], value=None)
|
302 |
+
|
303 |
with gr.Blocks() as iface:
|
304 |
gr.Markdown("# Multi-Pipeline Transcription")
|
305 |
gr.Markdown("Transcribe audio using multiple pipelines and models.")
|