accent-detector / README.md
amirjamali's picture
Add Dockerfile and Streamlit configuration; implement video download with alternative YouTube sources, enhance error handling, and improve file upload processing
aca25cc unverified
---
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/)