Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -3,10 +3,12 @@ import gradio as gr
|
|
3 |
import pytube as pt
|
4 |
|
5 |
pipe = pipeline(model="Hoft/whisper-small-swedish-asr") # change to "your-username/the-name-you-picked"
|
|
|
6 |
|
7 |
def microphone_or_file_transcribe(audio):
|
8 |
text = pipe(audio)["text"]
|
9 |
-
|
|
|
10 |
|
11 |
def youtube_transcribe(url):
|
12 |
yt = pt.YouTube(url)
|
@@ -24,7 +26,7 @@ app = gr.Blocks()
|
|
24 |
microphone_tab = gr.Interface(
|
25 |
fn=microphone_or_file_transcribe,
|
26 |
inputs=gr.Audio(source="microphone", type="filepath"),
|
27 |
-
outputs="text",
|
28 |
title="Whisper Small Swedish",
|
29 |
description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
|
30 |
)
|
@@ -40,7 +42,7 @@ youtube_tab = gr.Interface(
|
|
40 |
file_tab = gr.Interface(
|
41 |
fn=microphone_or_file_transcribe,
|
42 |
inputs= gr.inputs.Audio(source="upload", type="filepath"),
|
43 |
-
outputs="text",
|
44 |
title="Whisper Small Swedish",
|
45 |
description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
|
46 |
)
|
|
|
3 |
import pytube as pt
|
4 |
|
5 |
pipe = pipeline(model="Hoft/whisper-small-swedish-asr") # change to "your-username/the-name-you-picked"
|
6 |
+
sa = pipeline('sentiment-analysis', model='marma/bert-base-swedish-cased-sentiment')
|
7 |
|
8 |
def microphone_or_file_transcribe(audio):
|
9 |
text = pipe(audio)["text"]
|
10 |
+
sa_result = sa(text)[0]
|
11 |
+
return text, sa_result['label']
|
12 |
|
13 |
def youtube_transcribe(url):
|
14 |
yt = pt.YouTube(url)
|
|
|
26 |
microphone_tab = gr.Interface(
|
27 |
fn=microphone_or_file_transcribe,
|
28 |
inputs=gr.Audio(source="microphone", type="filepath"),
|
29 |
+
outputs=["text", "text"],
|
30 |
title="Whisper Small Swedish",
|
31 |
description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
|
32 |
)
|
|
|
42 |
file_tab = gr.Interface(
|
43 |
fn=microphone_or_file_transcribe,
|
44 |
inputs= gr.inputs.Audio(source="upload", type="filepath"),
|
45 |
+
outputs=["text", "text"],
|
46 |
title="Whisper Small Swedish",
|
47 |
description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper small model.",
|
48 |
)
|