Spaces:
Runtime error
Runtime error
Use microphone and add prompt text
Browse files
app.py
CHANGED
@@ -1,3 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import torch
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
modle_id = "models/ummonk/distilhubert-finetuned-accents"
|
5 |
+
pipe = pipeline("audio-classification", model=model_id)
|
6 |
+
|
7 |
+
def classify_audio(filepath):
|
8 |
+
preds = pipe(filepath)
|
9 |
+
outputs = {}
|
10 |
+
for p in preds:
|
11 |
+
outputs[p["label"]] = p["score"]
|
12 |
+
return outputs
|
13 |
+
|
14 |
import gradio as gr
|
15 |
|
16 |
+
demo = gr.Interface(
|
17 |
+
fn=classify_audio,
|
18 |
+
inputs=gr.Audio(sources="microphone", type="filepath"),
|
19 |
+
outputs=gr.outputs.Label(),
|
20 |
+
title="Accent Guesser",
|
21 |
+
description="Say the following text\nPlease call Stella. Ask her to bring these things with her from the store: Six spoons of fresh snow peas, five thick slabs of blue cheese, and maybe a snack for her brother Bob. We also need a small plastic snake and a big toy frog for the kids. She can scoop these things into three red bags, and we will go meet her Wednesday at the train station."
|
22 |
+
)
|
23 |
+
|
24 |
+
demo.launch(debug=True)
|