Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,32 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
|
4 |
+
pipe = pipeline(model="ZinebSN/whisper-small-swedish-Test-5it") # change to "your-username/the-name-you-picked"
|
5 |
+
|
6 |
+
def transcribe(audio=None, file=None, youtube=None):
|
7 |
+
if (audio is None) and (file is None) and (youtube is None):
|
8 |
+
return "No audio provided!"
|
9 |
+
elif audio is not None:
|
10 |
+
input=audio
|
11 |
+
elif file is not None:
|
12 |
+
input=file
|
13 |
+
elif youtube is not None:
|
14 |
+
yt=pt.YouTube("https://www.youtube.com/watch?v=4KI9BBW_aP8")
|
15 |
+
stream=yt.streams.filter(only_audio=True)[0]
|
16 |
+
stream.download(filename="audio.mp3")
|
17 |
+
input=audio
|
18 |
+
text = pipe(input)["text"]
|
19 |
+
return text
|
20 |
+
|
21 |
+
iface = gr.Interface(
|
22 |
+
fn=transcribe,
|
23 |
+
inputs=[
|
24 |
+
gr.Audio(source="microphone", type="filepath", interactive=True),
|
25 |
+
gr.Audio(source="upload", type="filepath", interactive=True),
|
26 |
+
gr.Text(label="URL (YouTube, etc.)")],
|
27 |
+
outputs="text",
|
28 |
+
title="Whisper Small Swedish",
|
29 |
+
description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
|
30 |
+
)
|
31 |
+
|
32 |
+
iface.launch()
|