Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,18 +1,23 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
model_id = "sanchit-gandhi/distilhubert-finetuned-gtzan"
|
4 |
-
pipe = pipeline("audio-classification", model=model_id)
|
5 |
|
6 |
-
|
7 |
-
preds = pipe(filepath)
|
8 |
-
outputs = {}
|
9 |
-
for p in preds:
|
10 |
-
outputs[p["label"]] = p["score"]
|
11 |
-
return outputs
|
12 |
|
13 |
-
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
fn=
|
|
|
|
|
17 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
demo.launch(debug=True)
|
|
|
1 |
+
import gradio as gr
|
|
|
|
|
|
|
2 |
|
3 |
+
demo = gr.Blocks()
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
mic_transcribe = gr.Interface(
|
6 |
+
fn=transcribe_speech,
|
7 |
+
inputs=gr.Audio(sources="microphone", type="filepath"),
|
8 |
+
outputs=gr.outputs.Textbox(),
|
9 |
+
)
|
10 |
|
11 |
+
file_transcribe = gr.Interface(
|
12 |
+
fn=transcribe_speech,
|
13 |
+
inputs=gr.Audio(sources="upload", type="filepath"),
|
14 |
+
outputs=gr.outputs.Textbox(),
|
15 |
)
|
16 |
+
|
17 |
+
with demo:
|
18 |
+
gr.TabbedInterface(
|
19 |
+
[mic_transcribe, file_transcribe],
|
20 |
+
["Transcribe Microphone", "Transcribe Audio File"],
|
21 |
+
)
|
22 |
+
|
23 |
demo.launch(debug=True)
|