MehdiAbdellaoui commited on
Commit
821ae6c
1 Parent(s): da387df

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -11,6 +11,13 @@ def transcribe_and_translate(audio):
11
  translation = translation_pipe(transcription)[0]['translation_text']
12
  return transcription, translation
13
 
 
 
 
 
 
 
 
14
  with gr.Blocks() as demo_realtime:
15
  with gr.Tab("Real-time Swedish to English Transcription and Translation"):
16
  gr.Interface(
@@ -18,17 +25,17 @@ with gr.Blocks() as demo_realtime:
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.Blocks() as demo_youtube:
25
  with gr.Tab("Youtube Video Transcription and Translation"):
26
  gr.Interface(
27
- fn=transcribe_and_translate,
28
- inputs=gr.Audio(source="microphone", type="filepath"),
29
  outputs=[gr.Textbox(), gr.Textbox()],
30
- title="Whisper Small Swedish to English Translator",
31
- description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model, and Swedish to English translation using a small T5 model",
32
  )
33
 
34
  demo_realtime.launch(debug=True)
 
11
  translation = translation_pipe(transcription)[0]['translation_text']
12
  return transcription, translation
13
 
14
+
15
+ def transcribe_and_translate_yt(link):
16
+ yt = YouTube(video_link)
17
+ audio = yt.streams.filter(only_audio=True).first().download()
18
+
19
+ return transcribe_and_translate(audio)
20
+
21
  with gr.Blocks() as demo_realtime:
22
  with gr.Tab("Real-time Swedish to English Transcription and Translation"):
23
  gr.Interface(
 
25
  inputs=gr.Audio(source="microphone", type="filepath"),
26
  outputs=[gr.Textbox(), gr.Textbox()],
27
  title="Whisper Small Swedish to English Translator",
28
+ description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model, and Swedish to English translation",
29
  )
30
 
31
  with gr.Blocks() as demo_youtube:
32
  with gr.Tab("Youtube Video Transcription and Translation"):
33
  gr.Interface(
34
+ fn=transcribe_and_translate_youtube,
35
+ inputs=gr.Textbox("text", label="Enter YouTube Video Link"),
36
  outputs=[gr.Textbox(), gr.Textbox()],
37
+ title="Whisper Small Swedish to English Translator - Youtube Video",
38
+ description="Paste the link of a YouTube Video in Swedish to transcribe and translate it",
39
  )
40
 
41
  demo_realtime.launch(debug=True)