Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,23 @@
|
|
1 |
from transformers import pipeline
|
|
|
2 |
|
3 |
model_id = "Teapack1/model_KWS" # update with your model id
|
4 |
-
pipe = pipeline("
|
5 |
|
6 |
-
import gradio as gr
|
7 |
|
8 |
title = "Keyword Spotting Wav2Vec2"
|
9 |
description = "Gradio demo for finetuned Wav2Vec2 model on a custom dataset to perform keyword spotting task. Classes are scene 1, scene 2, scene 3, yes, no and stop."
|
10 |
|
11 |
|
12 |
-
def
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
"language": "sinhalese",
|
19 |
-
}, # update with the language you've fine-tuned on
|
20 |
-
chunk_length_s=30,
|
21 |
-
batch_size=8,
|
22 |
-
)
|
23 |
-
return output["text"]
|
24 |
-
|
25 |
-
demo = gr.Blocks()
|
26 |
|
27 |
-
mic_transcribe = gr.Interface(
|
28 |
-
fn=transcribe_speech,
|
29 |
-
inputs=gr.Audio(sources="microphone", type="filepath"),
|
30 |
-
outputs=gr.outputs.Textbox(),
|
31 |
-
)
|
32 |
|
33 |
-
|
34 |
-
fn=
|
35 |
-
inputs=gr.Audio(sources="upload", type="filepath"),
|
36 |
-
outputs=gr.outputs.Textbox(),
|
37 |
)
|
38 |
-
|
39 |
-
with demo:
|
40 |
-
gr.TabbedInterface(
|
41 |
-
[mic_transcribe, file_transcribe],
|
42 |
-
["Transcribe Microphone", "Transcribe Audio File"],
|
43 |
-
)
|
44 |
-
|
45 |
demo.launch(debug=True)
|
|
|
1 |
from transformers import pipeline
|
2 |
+
import gradio as gr
|
3 |
|
4 |
model_id = "Teapack1/model_KWS" # update with your model id
|
5 |
+
pipe = pipeline("audio-classification", model=model_id)
|
6 |
|
|
|
7 |
|
8 |
title = "Keyword Spotting Wav2Vec2"
|
9 |
description = "Gradio demo for finetuned Wav2Vec2 model on a custom dataset to perform keyword spotting task. Classes are scene 1, scene 2, scene 3, yes, no and stop."
|
10 |
|
11 |
|
12 |
+
def classify_audio(filepath):
|
13 |
+
preds = pipe(filepath)
|
14 |
+
outputs = {}
|
15 |
+
for p in preds:
|
16 |
+
outputs[p["label"]] = p["score"]
|
17 |
+
return outputs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
demo = gr.Interface(
|
21 |
+
fn=classify_audio, inputs=gr.Audio(type="filepath"), outputs=gr.outputs.Label()
|
|
|
|
|
22 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
demo.launch(debug=True)
|