Spaces:
Running
Running
MaximilianChen
commited on
Commit
·
36bd290
1
Parent(s):
c65aacc
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,25 @@
|
|
1 |
-
pip install transformers
|
2 |
-
|
3 |
from transformers import pipeline
|
4 |
import gradio as gr
|
5 |
|
6 |
-
|
|
|
7 |
|
8 |
-
def
|
9 |
-
|
10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
|
12 |
-
|
13 |
-
|
|
|
14 |
inputs=[
|
15 |
-
gr.Audio(
|
16 |
-
gr.Audio(
|
17 |
-
],
|
18 |
outputs="text",
|
19 |
-
|
20 |
-
description="Realtime demo for Catalan speech recognition using a fine-tuned Whisper small model.",
|
21 |
-
)
|
22 |
-
|
23 |
-
iface.launch()
|
|
|
|
|
|
|
1 |
from transformers import pipeline
|
2 |
import gradio as gr
|
3 |
|
4 |
+
model = pipeline(model='MaximilianChen/Casper')
|
5 |
+
|
6 |
|
7 |
+
def transcribe_audio(mic=None, file=None):
|
8 |
+
if mic is not None:
|
9 |
+
audio = mic
|
10 |
+
elif file is not None:
|
11 |
+
audio = file
|
12 |
+
else:
|
13 |
+
return "You must either provide a mic recording or a file"
|
14 |
+
transcription = model(audio)["text"]
|
15 |
+
return transcription
|
16 |
|
17 |
+
|
18 |
+
gr.Interface(
|
19 |
+
fn=transcribe_audio,
|
20 |
inputs=[
|
21 |
+
gr.Audio(source="microphone", type="filepath", optional=True),
|
22 |
+
gr.Audio(source="upload", type="filepath", optional=True),
|
23 |
+
],
|
24 |
outputs="text",
|
25 |
+
).launch()
|
|
|
|
|
|
|
|