Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from deep_translator import GoogleTranslator
|
|
4 |
from transformers import pipeline
|
5 |
import os
|
6 |
from gtts import gTTS
|
|
|
7 |
|
8 |
pipe = pipeline(model="freeja/lab2-whisper-sv")
|
9 |
|
@@ -32,13 +33,13 @@ def text_to_speech(text,language):
|
|
32 |
gTTS(text,lang,slow=False)
|
33 |
|
34 |
def transcribe_video(URL):
|
35 |
-
video =
|
36 |
yt = video.streams.get_audio_only()
|
37 |
yt.download()
|
38 |
text = pipe(yt)["text"]
|
39 |
return text
|
40 |
|
41 |
-
iface = gr.Interface(
|
42 |
fn=transcribe_audio,
|
43 |
inputs=[
|
44 |
gr.Audio(source="microphone", type="filepath", label="Transcribe from Microphone"),
|
@@ -46,6 +47,27 @@ iface = gr.Interface(
|
|
46 |
],
|
47 |
outputs="text",
|
48 |
title="Whisper Small Swedish",
|
49 |
-
description="Realtime demo for Swedish speech recognition with translation using a fine-tuned Whisper small model")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
iface.launch()
|
|
|
4 |
from transformers import pipeline
|
5 |
import os
|
6 |
from gtts import gTTS
|
7 |
+
from pytube import YouTube
|
8 |
|
9 |
pipe = pipeline(model="freeja/lab2-whisper-sv")
|
10 |
|
|
|
33 |
gTTS(text,lang,slow=False)
|
34 |
|
35 |
def transcribe_video(URL):
|
36 |
+
video = YouTube(URL)
|
37 |
yt = video.streams.get_audio_only()
|
38 |
yt.download()
|
39 |
text = pipe(yt)["text"]
|
40 |
return text
|
41 |
|
42 |
+
"""iface = gr.Interface(
|
43 |
fn=transcribe_audio,
|
44 |
inputs=[
|
45 |
gr.Audio(source="microphone", type="filepath", label="Transcribe from Microphone"),
|
|
|
47 |
],
|
48 |
outputs="text",
|
49 |
title="Whisper Small Swedish",
|
50 |
+
description="Realtime demo for Swedish speech recognition with translation using a fine-tuned Whisper small model")"""
|
51 |
+
|
52 |
+
video_transcription = gr.Interface(
|
53 |
+
fn = transcribe_video,
|
54 |
+
inputs = "text",
|
55 |
+
outputs = "text",
|
56 |
+
title = "Whisper Small Swedish",
|
57 |
+
description = "Realtime demo for Swedish speech recognition with translation using a fine-tuned Whisper small model"",
|
58 |
+
)
|
59 |
+
|
60 |
+
audio_transcription = gr.Interface(
|
61 |
+
fn=transcribe_audio,
|
62 |
+
inputs=[
|
63 |
+
gr.Audio(source="microphone", type="filepath", label="Transcribe from Microphone"),
|
64 |
+
gr.Dropdown(["English","Spanish","Dutch","French","Italian"], value="English", label="Translate to ")
|
65 |
+
],
|
66 |
+
outputs="text",
|
67 |
+
title="Whisper Small Swedish",
|
68 |
+
description="Realtime demo for Swedish speech recognition with translation using a fine-tuned Whisper small model"",
|
69 |
+
)
|
70 |
+
|
71 |
+
iface = gr.TabbedInterface([audio_transcription, video_transcription], ["Transcribe Audio", "Transcribe Video"])
|
72 |
|
73 |
iface.launch()
|