Update app.py
Browse files
app.py
CHANGED
|
@@ -12,7 +12,6 @@ from transformers import logging
|
|
| 12 |
warnings.filterwarnings("ignore")
|
| 13 |
logging.set_verbosity_error()
|
| 14 |
|
| 15 |
-
|
| 16 |
# Updated models by language
|
| 17 |
MODELS = {
|
| 18 |
"es": [
|
|
@@ -23,7 +22,7 @@ MODELS = {
|
|
| 23 |
"en": [
|
| 24 |
"openai/whisper-large-v3",
|
| 25 |
"facebook/wav2vec2-large-960h",
|
| 26 |
-
"microsoft/wav2vec2-base-
|
| 27 |
],
|
| 28 |
"pt": [
|
| 29 |
"facebook/wav2vec2-large-xlsr-53-portuguese",
|
|
@@ -103,18 +102,18 @@ def combined_interface(audio):
|
|
| 103 |
language, model_options = detect_and_select_model(audio)
|
| 104 |
selected_model = model_options[0]
|
| 105 |
|
| 106 |
-
yield language,
|
| 107 |
|
| 108 |
full_transcription = ""
|
| 109 |
for partial_transcription in transcribe_audio_stream(audio, selected_model):
|
| 110 |
full_transcription += partial_transcription + " "
|
| 111 |
-
yield language,
|
| 112 |
|
| 113 |
# Clean up temporary files
|
| 114 |
os.remove("converted_audio.wav")
|
| 115 |
|
| 116 |
except Exception as e:
|
| 117 |
-
yield str(e),
|
| 118 |
|
| 119 |
iface = gr.Interface(
|
| 120 |
fn=combined_interface,
|
|
@@ -126,7 +125,7 @@ iface = gr.Interface(
|
|
| 126 |
gr.Textbox(label="Transcription", lines=10)
|
| 127 |
],
|
| 128 |
title="Multilingual Audio Transcriber with Real-time Display",
|
| 129 |
-
description="Upload an audio file to detect the language, select the transcription model, and get the transcription in real-time. Optimized for Spanish and
|
| 130 |
live=True
|
| 131 |
)
|
| 132 |
|
|
|
|
| 12 |
warnings.filterwarnings("ignore")
|
| 13 |
logging.set_verbosity_error()
|
| 14 |
|
|
|
|
| 15 |
# Updated models by language
|
| 16 |
MODELS = {
|
| 17 |
"es": [
|
|
|
|
| 22 |
"en": [
|
| 23 |
"openai/whisper-large-v3",
|
| 24 |
"facebook/wav2vec2-large-960h",
|
| 25 |
+
"microsoft/wav2vec2-base-960h"
|
| 26 |
],
|
| 27 |
"pt": [
|
| 28 |
"facebook/wav2vec2-large-xlsr-53-portuguese",
|
|
|
|
| 102 |
language, model_options = detect_and_select_model(audio)
|
| 103 |
selected_model = model_options[0]
|
| 104 |
|
| 105 |
+
yield language, model_options, selected_model, ""
|
| 106 |
|
| 107 |
full_transcription = ""
|
| 108 |
for partial_transcription in transcribe_audio_stream(audio, selected_model):
|
| 109 |
full_transcription += partial_transcription + " "
|
| 110 |
+
yield language, model_options, selected_model, full_transcription.strip()
|
| 111 |
|
| 112 |
# Clean up temporary files
|
| 113 |
os.remove("converted_audio.wav")
|
| 114 |
|
| 115 |
except Exception as e:
|
| 116 |
+
yield str(e), [], "", "An error occurred during processing."
|
| 117 |
|
| 118 |
iface = gr.Interface(
|
| 119 |
fn=combined_interface,
|
|
|
|
| 125 |
gr.Textbox(label="Transcription", lines=10)
|
| 126 |
],
|
| 127 |
title="Multilingual Audio Transcriber with Real-time Display",
|
| 128 |
+
description="Upload an audio file to detect the language, select the transcription model, and get the transcription in real-time. Optimized for Spanish, English, and Portuguese.",
|
| 129 |
live=True
|
| 130 |
)
|
| 131 |
|