femifoly commited on
Commit
5721224
·
1 Parent(s): 09f23d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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="Nikolajvestergaard/Japanese_Fine_Tuned_Whisper_Model")
6
 
7
  def translate_and_transcribe(audio):
8
  translator = Translator()
9
 
10
- # Transcribe Japanese 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 Japanese
18
- pronunciation = translator.translate(transcription, dest='ja').pronunciation
19
 
20
  return transcription, pronunciation, translation
21
 
22
- input_audio = gr.inputs.Audio(label="Upload your Japanese speech here. Try to say 'Kon'nichiwa', 'Arigatō' or perhaps 'Sayōnara'", 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,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="Japanese Automatic Speech Recognition, Pronunciation and Translation",
32
- description="Record Japanese 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()
 
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()