ummonk commited on
Commit
a4fd417
·
verified ·
1 Parent(s): 40fe354

Use microphone and add prompt text

Browse files
Files changed (1) hide show
  1. app.py +22 -1
app.py CHANGED
@@ -1,3 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
 
3
- gr.load("models/ummonk/distilhubert-finetuned-accents").launch()
 
 
 
 
 
 
 
 
 
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)