Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -494,25 +494,26 @@ def transcribe_audio(input_source, pipeline_type, model_id, dtype, batch_size, d
|
|
494 |
if verbose:
|
495 |
yield verbose_messages, "", None
|
496 |
|
497 |
-
# Determine if input_source is a URL or
|
498 |
audio_path = None
|
499 |
is_temp_file = False
|
500 |
|
501 |
-
if isinstance(input_source, str)
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
|
|
516 |
is_temp_file = False
|
517 |
else:
|
518 |
error_msg = "No valid audio source provided."
|
@@ -620,14 +621,13 @@ def transcribe_audio(input_source, pipeline_type, model_id, dtype, batch_size, d
|
|
620 |
# Clean up temporary audio files
|
621 |
if audio_path and is_temp_file and os.path.exists(audio_path):
|
622 |
os.remove(audio_path)
|
623 |
-
|
624 |
with gr.Blocks() as iface:
|
625 |
-
gr.Markdown("#
|
626 |
-
gr.Markdown("Transcribe audio using multiple pipelines and models.")
|
627 |
|
628 |
with gr.Row():
|
629 |
-
|
630 |
-
input_source = gr.Textbox(label="Audio Source (Upload a file or enter a URL/YouTube URL)")
|
631 |
pipeline_type = gr.Dropdown(
|
632 |
choices=["faster-batched", "faster-sequenced", "transformers"],
|
633 |
label="Pipeline Type",
|
|
|
494 |
if verbose:
|
495 |
yield verbose_messages, "", None
|
496 |
|
497 |
+
# Determine if input_source is a URL, file path, or uploaded audio
|
498 |
audio_path = None
|
499 |
is_temp_file = False
|
500 |
|
501 |
+
if isinstance(input_source, str):
|
502 |
+
if input_source.startswith('http://') or input_source.startswith('https://'):
|
503 |
+
# Input source is a URL
|
504 |
+
audio_path, is_temp_file = download_audio(input_source, download_method)
|
505 |
+
if not audio_path:
|
506 |
+
error_msg = f"Error downloading audio from {input_source} using method {download_method}. Check logs for details."
|
507 |
+
logging.error(error_msg)
|
508 |
+
yield verbose_messages + error_msg, "", None
|
509 |
+
return
|
510 |
+
elif os.path.exists(input_source):
|
511 |
+
# Input source is a local file path
|
512 |
+
audio_path = input_source
|
513 |
+
is_temp_file = False
|
514 |
+
elif isinstance(input_source, dict) and 'path' in input_source:
|
515 |
+
# Input source is an uploaded audio file
|
516 |
+
audio_path = input_source['path']
|
517 |
is_temp_file = False
|
518 |
else:
|
519 |
error_msg = "No valid audio source provided."
|
|
|
621 |
# Clean up temporary audio files
|
622 |
if audio_path and is_temp_file and os.path.exists(audio_path):
|
623 |
os.remove(audio_path)
|
624 |
+
|
625 |
with gr.Blocks() as iface:
|
626 |
+
gr.Markdown("# Audio Transcription")
|
627 |
+
gr.Markdown("Transcribe audio using multiple pipelines and (Faster) Whisper models.")
|
628 |
|
629 |
with gr.Row():
|
630 |
+
input_source = gr.Audio(label="Audio Source (Upload a file or enter a URL/YouTube URL)")
|
|
|
631 |
pipeline_type = gr.Dropdown(
|
632 |
choices=["faster-batched", "faster-sequenced", "transformers"],
|
633 |
label="Pipeline Type",
|