Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,24 +2,24 @@ import gradio as gr
|
|
2 |
from googletrans import Translator
|
3 |
from transformers import pipeline
|
4 |
|
5 |
-
pipe = pipeline(model="
|
6 |
|
7 |
def translate_and_transcribe(audio):
|
8 |
translator = Translator()
|
9 |
|
10 |
-
# Transcribe
|
11 |
transcription = pipe(audio)["text"]
|
12 |
|
13 |
# Translate the transcription to English
|
14 |
result = translator.translate(transcription, dest='en')
|
15 |
translation = result.text
|
16 |
|
17 |
-
# Get the pronunciation of the transcription in
|
18 |
-
pronunciation = translator.translate(transcription, dest='
|
19 |
|
20 |
return transcription, pronunciation, translation
|
21 |
|
22 |
-
input_audio = gr.inputs.Audio(label="Upload your
|
23 |
output_textbox1 = gr.outputs.Textbox(label="Transcription")
|
24 |
output_textbox2 = gr.outputs.Textbox(label="Pronunciation")
|
25 |
output_textbox3 = gr.outputs.Textbox(label="Translation")
|
@@ -28,8 +28,8 @@ iface = gr.Interface(
|
|
28 |
fn=translate_and_transcribe,
|
29 |
inputs=input_audio,
|
30 |
outputs=[output_textbox1, output_textbox2, output_textbox3],
|
31 |
-
title="
|
32 |
-
description="Record
|
33 |
)
|
34 |
|
35 |
iface.launch()
|
|
|
2 |
from googletrans import Translator
|
3 |
from transformers import pipeline
|
4 |
|
5 |
+
pipe = pipeline(model="femifoly/Spanish-Fine-Tune-whisper")
|
6 |
|
7 |
def translate_and_transcribe(audio):
|
8 |
translator = Translator()
|
9 |
|
10 |
+
# Transcribe Spanish audio to text
|
11 |
transcription = pipe(audio)["text"]
|
12 |
|
13 |
# Translate the transcription to English
|
14 |
result = translator.translate(transcription, dest='en')
|
15 |
translation = result.text
|
16 |
|
17 |
+
# Get the pronunciation of the transcription in Spanish
|
18 |
+
pronunciation = translator.translate(transcription, dest='es').pronunciation
|
19 |
|
20 |
return transcription, pronunciation, translation
|
21 |
|
22 |
+
input_audio = gr.inputs.Audio(label="Upload your Spanish speech here. Try to say 'Hola', 'Como estas' or perhaps 'Que tal'", source="microphone", type="filepath")
|
23 |
output_textbox1 = gr.outputs.Textbox(label="Transcription")
|
24 |
output_textbox2 = gr.outputs.Textbox(label="Pronunciation")
|
25 |
output_textbox3 = gr.outputs.Textbox(label="Translation")
|
|
|
28 |
fn=translate_and_transcribe,
|
29 |
inputs=input_audio,
|
30 |
outputs=[output_textbox1, output_textbox2, output_textbox3],
|
31 |
+
title="Spanish Automatic Speech Recognition, Pronunciation and Translation",
|
32 |
+
description="Record Spanish speech to get its pronunciation and translate it to English. All done by using a fine-tuned version of the tiny Whisper model which is connected to a Google Translate API"
|
33 |
)
|
34 |
|
35 |
iface.launch()
|