MehdiAbdellaoui commited on
Commit
087f485
1 Parent(s): d5c74e2

Add tabs to interface

Browse files
Files changed (1) hide show
  1. app.py +20 -8
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from transformers import pipeline
2
  import gradio as gr
 
3
 
4
  transcription_pipe = pipeline(model="explorall/whisper-small-sv-dropout-6mb")
5
  translation_pipe = pipeline(model="Helsinki-NLP/opus-mt-sv-en")
@@ -10,12 +11,23 @@ def transcribe_and_translate(audio):
10
  translation = translation_pipe(transcription)[0]['translation_text']
11
  return transcription, translation
12
 
13
- iface = gr.Interface(
14
- fn=transcribe_and_translate,
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
- )
 
 
20
 
21
- iface.launch()
 
 
 
 
 
 
 
 
 
 
1
  from transformers import pipeline
2
  import gradio as gr
3
+ from pytube import YouTube
4
 
5
  transcription_pipe = pipeline(model="explorall/whisper-small-sv-dropout-6mb")
6
  translation_pipe = pipeline(model="Helsinki-NLP/opus-mt-sv-en")
 
11
  translation = translation_pipe(transcription)[0]['translation_text']
12
  return transcription, translation
13
 
14
+ with gr.Blocks() as demo:
15
+ with gr.Tab("Real-time Swedish to English Transcription and Translation"):
16
+ gr.Interface(
17
+ fn=transcribe_and_translate,
18
+ inputs=gr.Audio(source="microphone", type="filepath"),
19
+ outputs=[gr.Textbox(), gr.Textbox()],
20
+ title="Whisper Small Swedish to English Translator",
21
+ description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model, and Swedish to English translation using a small T5 model",
22
+ )
23
 
24
+ with gr.Tab("Youtube Video Transcription and Translation"):
25
+ gr.Interface(
26
+ fn=transcribe_and_translate,
27
+ inputs=gr.Audio(source="microphone", type="filepath"),
28
+ outputs=[gr.Textbox(), gr.Textbox()],
29
+ title="Whisper Small Swedish to English Translator",
30
+ description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model, and Swedish to English translation using a small T5 model",
31
+ )
32
+
33
+ demo.launch(debug=True)