accent-guesser / app.py
ummonk's picture
Update description
64929cc verified
raw
history blame
1.23 kB
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
description = '''
Only designed for Anglosphere accents (North American, British, and Australian / New Zealand). Top guess correctly guesses birthplace ~30% of the time, but it is pretty reliable at guessing whether the accent is North American or British.
Record the following text within 30 seconds and submit to guess accent:
> 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 = gr.Interface(
fn=classify_audio,
inputs=gr.Audio(sources="microphone", type="filepath"),
outputs=gr.Label(),
title="Accent Guesser",
description=description
)
demo.launch(debug=True)