File size: 5,530 Bytes
f2eb753
635694f
 
 
 
f2eb753
 
 
 
635694f
 
 
f2eb753
635694f
f2eb753
 
 
635694f
3b528f9
635694f
 
 
 
 
 
 
 
 
3b528f9
b15f0c7
635694f
 
 
 
 
 
 
 
 
 
7eb21f1
 
 
 
aca25cc
7eb21f1
aca25cc
7eb21f1
aca25cc
 
 
 
 
 
7eb21f1
 
 
 
 
 
 
 
 
 
 
 
aca25cc
 
 
 
 
 
 
635694f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55dbd8d
635694f
55dbd8d
 
 
 
 
 
635694f
3b528f9
55dbd8d
 
 
 
 
 
 
 
 
aca25cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b15f0c7
 
635694f
b15f0c7
635694f
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
---
title: English Accent Detector
emoji: 🎤
colorFrom: blue
colorTo: green
sdk: docker
app_port: 8501
tags:
- streamlit
- audio
- accent-detection
- hiring
pinned: false
short_description: Detect and analyze English accents from videos
license: mit
---

# 🎤 English Accent Detection Tool

This app analyzes a speaker's English accent from video URLs or audio uploads, providing detailed insights for hiring evaluation purposes.

## Features
- **Video URL Processing**: Accept and analyze videos from Loom, YouTube, or direct MP4 links
- **Audio Upload Support**: Directly upload audio files for analysis
- **English Accent Classification**: Identify specific English accents (American, British, Australian, etc.)
- **Confidence Scoring**: Get detailed confidence scores for English proficiency
- **Detailed Analysis**: Receive expert-like explanations about accent characteristics
- **Visual Feedback**: View audio waveforms and listen to the processed audio

## Usage
1. **Via Video URL**:
   - Enter a public video URL (Loom, YouTube, direct MP4, etc.)
   - Click "Analyze Video"
   - View the accent classification, confidence scores, and analysis

2. **Via Audio Upload**:
   - Upload an audio file (WAV, MP3, M4A, OGG)
   - Click "Analyze Audio"
   - View the results

### Troubleshooting YouTube Authentication Issues

If you encounter errors like `Sign in to confirm you're not a bot` when using YouTube videos:

1. **Use a different video source** (RECOMMENDED):
   - Try using Loom, Vimeo, or direct MP4 links instead of YouTube
   - These sources are more reliable and have fewer authentication requirements

2. **Use alternative YouTube frontends**:
   - The app now automatically tries alternative YouTube frontends (Invidious, Piped)
   - Make sure the "Try alternative YouTube source" checkbox is checked
   - These frontend services can bypass some YouTube restrictions

3. **Using cookies for YouTube authentication**:
   - The app supports uploading a cookies.txt file for YouTube authentication
   - You can export cookies from your browser using browser extensions like "Get cookies.txt"
   - Or use yt-dlp's built-in browser cookie extraction:
     ```
     # Install yt-dlp if you don't have it
     pip install yt-dlp
     
     # Extract cookies from your browser (replace chrome with your browser)
     yt-dlp --cookies-from-browser chrome -o cookies.txt https://youtube.com
     ```
   - Upload the generated cookies file in the app interface

4. **Update yt-dlp for better YouTube support**:
   - If running outside Docker, update yt-dlp to the latest version:
     ```
     pip install -U yt-dlp
     ```
   - YouTube frequently updates its anti-bot measures, and newer yt-dlp versions often have fixes

## Technology Stack
- **Audio Processing**: FFmpeg, Librosa
- **ML Models**: SpeechBrain, Transformers
- **UI**: Streamlit
- **Deployment**: Docker

## Requirements
- Python 3.9+
- FFmpeg
- See requirements.txt for Python dependencies

## Deployment
The app is containerized with Docker for easy deployment. Use the included Dockerfile to build and run:

```bash
# Build the Docker image
docker build -t accent-detector .

# Run the container with volume mounting for better file handling
docker run -p 8501:8501 --volume /tmp/accent-detector:/app/uploads accent-detector 

# For Windows users:
docker run -p 8501:8501 --volume C:\temp\accent-detector:/app/uploads accent-detector
```

### Troubleshooting Upload Issues

If you encounter 403 Forbidden errors when uploading files:

1. Make sure your audio file is under 200MB
2. Try converting your audio to a WAV or MP3 format
3. For longer files, consider extracting just the speech segment
4. If uploading an MP4 video, ensure it's not encrypted or DRM-protected

### Troubleshooting Hugging Face Cache Issues

If you encounter errors related to Hugging Face model loading or cache permissions:

1. **Ensure proper volume mounts and permissions**:
   ```bash
   # Create local directories with proper permissions
   mkdir -p /tmp/accent-detector /tmp/huggingface-cache
   chmod 777 /tmp/accent-detector /tmp/huggingface-cache
   
   # Run with multiple volume mounts for both uploads and cache
   docker run -p 8501:8501 \
     --volume /tmp/accent-detector:/app/uploads \
     --volume /tmp/huggingface-cache:/app/.cache/huggingface \
     accent-detector
   ```

   On Windows:
   ```powershell
   # Create directories
   mkdir -Force C:\temp\accent-detector
   mkdir -Force C:\temp\huggingface-cache
   
   # Run with volume mounts
   docker run -p 8501:8501 `
     --volume C:\temp\accent-detector:/app/uploads `
     --volume C:\temp\huggingface-cache:/app/.cache/huggingface `
     accent-detector
   ```

2. **Reset the container and cache**:
   ```bash
   # Stop any running containers
   docker stop $(docker ps -q --filter ancestor=accent-detector)
   
   # Remove the container
   docker rm $(docker ps -a -q --filter ancestor=accent-detector)
   
   # Optionally clear the cache directories
   rm -rf /tmp/accent-detector/* /tmp/huggingface-cache/*
   
   # Rebuild and run
   docker build --no-cache -t accent-detector .
   docker run -p 8501:8501 --volume /tmp/accent-detector:/app/uploads --volume /tmp/huggingface-cache:/app/.cache/huggingface accent-detector
   ```

## Powered By
- [SpeechBrain](https://huggingface.co/speechbrain/lang-id-commonlanguage_ecapa)
- [Hugging Face Transformers](https://huggingface.co/speechbrain/lang-id-voxlingua107-ecapa)
- [Streamlit](https://streamlit.io)
- [FFmpeg](https://ffmpeg.org/)