File size: 1,014 Bytes
a4fd417
 
 
f071ce8
a4fd417
 
 
 
 
 
 
 
 
40fe354
 
a4fd417
 
 
 
 
850a92c
a4fd417
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import torch
from transformers import pipeline

model_id = "ummonk/distilhubert-finetuned-accents"
pipe = pipeline("audio-classification", model=model_id)

def classify_audio(filepath):
    preds = pipe(filepath)
    outputs = {}
    for p in preds:
        outputs[p["label"]] = p["score"]
    return outputs

import gradio as gr

demo = gr.Interface(
    fn=classify_audio,
    inputs=gr.Audio(sources="microphone", type="filepath"),
    outputs=gr.outputs.Label(),
    title="Accent Guesser",
    description="Only designed for Anglosphere accents (North American, British, and Australian / New Zealand).\nSay the following text:\n'Please 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.''"
)

demo.launch(debug=True)