Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the model | |
| pipe = pipeline("audio-classification", model="dima806/english_accents_classification") | |
| # Define the inference function | |
| def classify_accent(audio): | |
| result = pipe(audio) | |
| top_result = result[0] | |
| top3 = "\n".join([f"{r['label']}: {r['score']:.2f}" for r in result[:3]]) | |
| return f"🎤 Top Prediction: {top_result['label']} ({top_result['score']:.2f})\n\nTop 3:\n{top3}" | |
| # Launch the app | |
| gr.Interface( | |
| fn=classify_accent, | |
| inputs=gr.Audio(type="filepath"), | |
| outputs=gr.Textbox(), | |
| title="Accent Classifier 🎧", | |
| description="Upload an English audio sample to detect the speaker's accent.\nSupported: American, British, Indian, African, Australian.", | |
| allow_flagging="never" | |
| ).launch() | |