File size: 2,286 Bytes
0ae8686
 
c70e657
0ae8686
 
 
c70e657
0ae8686
 
 
d6192f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855b9e8
d6192f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855b9e8
d6192f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
title: English Accent Classifier
emoji: 🗣️
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 5.30.0
app_file: app.py
pinned: false
---
Overview

This web app uses Gradio and Hugging Face Transformers to classify English accents from audio samples.

Upload or record English speech, and the app predicts the speaker’s accent from:

American

British

Indian

African

Australian

Results are displayed in a clear, color-coded table showing confidence percentages, highlighting the top predicted accent.

Demo
Try the live app on Hugging Face Spaces:

https://huggingface.co/spaces/tusker123/accent-detection

Installation
Clone the repo and install dependencies:

bash
git clone https://github.com/your-username/english-accent-classifier.git
cd english-accent-classifier

# Optional: create and activate virtual environment
python -m venv venv
# On Linux/macOS:
source venv/bin/activate
# On Windows:
venv\Scripts\activate

pip install -r requirements.txt
If requirements.txt is not included, install manually:

bash
pip install gradio transformers torch
Running Locally
Start the app:

bash
python app.py
Open the local URL printed (usually http://127.0.0.1:7860) in your browser.

Deploying on Hugging Face Spaces
Create a new Space on Hugging Face using the Gradio SDK.

Upload your app.py and requirements.txt.

Ensure your app.py ends with:

#python
gr.Interface(...).launch()
(Do NOT use share=True on Spaces.)

Commit and wait for the build; your app will be publicly available.

How It Works
Uses the Hugging Face pipeline:

#python

pipeline("audio-classification", model="dima806/english_accents_classification")
Takes an audio input, predicts accents with confidence scores.

Displays top 3 accents in a styled table with the top accent highlighted.

Error Handling
Handles invalid audio files gracefully with user-friendly error messages.

Supports common audio formats like .wav and .mp3.

Customization
Change the model in app.py by editing:

#python
pipe = pipeline("audio-classification", model="your_model_name")
Customize UI elements and theme in the Gradio interface.

License & Acknowledgments

This project leverages open-source libraries:

Gradio

Transformers

Model by dima806


Contact
For inquiries or support, contact:
duncan.ngacha@gmail.com