MehdiAbdellaoui commited on
Commit
8839ec0
1 Parent(s): da224fd

Add sv-en translation model

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -1,16 +1,19 @@
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
- pipe = pipeline(model="Scalable-ML/whisper-small-sv-dropout-6mb-checkpoint-2000")
 
5
 
6
- def transcribe(audio):
7
- text = pipe(audio)["text"]
8
- return text
 
 
9
 
10
  iface = gr.Interface(
11
  fn=transcribe,
12
  inputs=gr.Audio(source="microphone", type="filepath"),
13
- outputs="text",
14
  title="Whisper Small Swedish to English Translator",
15
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model, and Swedish to English translation using a small T5 model",
16
  )
 
1
  from transformers import pipeline
2
  import gradio as gr
3
 
4
+ transcription_pipe = pipeline(model="Scalable-ML/whisper-small-sv-dropout-6mb-checkpoint-2000")
5
+ translation_pipe = pipeline(model="Helsinki-NLP/opus-mt-sv-en")
6
 
7
+
8
+ def transcribe_and_translate(audio):
9
+ transcription = transcription_pipe(audio)["text"]
10
+ translation = translation_pipe(transcription)["translation_text"]
11
+ return transcription, translation
12
 
13
  iface = gr.Interface(
14
  fn=transcribe,
15
  inputs=gr.Audio(source="microphone", type="filepath"),
16
+ outputs=[gr.Textbox(), gr.Textbox()],
17
  title="Whisper Small Swedish to English Translator",
18
  description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model, and Swedish to English translation using a small T5 model",
19
  )