Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
pipe = pipeline(model="Akseluhr/whisper-small-sv-Se-auhr-v2")
|
5 |
+
|
6 |
+
|
7 |
+
def transcribe(rec=None, file=None):
|
8 |
+
if rec is not None:
|
9 |
+
audio = rec
|
10 |
+
elif file is not None:
|
11 |
+
audio = file
|
12 |
+
else:
|
13 |
+
return "Provide a recording or a file."
|
14 |
+
|
15 |
+
text = pipe(audio)["text"]
|
16 |
+
return text
|
17 |
+
|
18 |
+
|
19 |
+
iface = gr.Interface(
|
20 |
+
fn=transcribe,
|
21 |
+
inputs=[
|
22 |
+
gr.Audio(source="microphone", type="filepath", optional=True),
|
23 |
+
gr.Audio(source="upload", type="filepath", optional=True),
|
24 |
+
],
|
25 |
+
outputs="text",
|
26 |
+
title="Whisper Small Swedish",
|
27 |
+
description="Realtime demo for Swedish speech recognition using a fine-tuned Whisper model.",
|
28 |
+
)
|
29 |
+
|
30 |
+
|
31 |
+
iface.launch()
|