Spaces:
Sleeping
Sleeping
--- | |
title: Accent Classifier | |
emoji: 🎙️ | |
colorFrom: indigo | |
colorTo: cyan | |
sdk: gradio | |
sdk_version: "3.38.1" | |
app_file: app.py | |
pinned: false | |
--- | |
# Accent Classifier 🎙️ | |
This Gradio app downloads a public YouTube or Vimeo video, extracts its audio, and classifies the speaker (as a proxy for accent) using a Hugging Face model. It’s perfect for demonstrating how to hook up **yt-dlp**, **ffmpeg**, and a **wav2vec2** pipeline in one slick interface—no rocket science required (just a little AI eavesdropping). | |
--- | |
## 🛠️ How It Works | |
1. **Input**: You paste a *public* YouTube or Vimeo video URL into the Gradio textbox. | |
2. **Download**: Under the hood, `yt-dlp` fetches the video’s best audio stream and saves it as `downloaded_video.mp4`. | |
3. **Extract Audio**: `ffmpeg` converts that MP4 into a WAV file (`extracted_audio.wav`) at 16 kHz, mono—exactly what speech models crave. | |
4. **Classify**: A Hugging Face `pipeline("audio-classification", model="superb/wav2vec2-base-superb-sid")` processes the WAV file and returns a speaker ID (used here as an accent proxy) plus confidence. | |
5. **Cleanup**: Temporary files are removed automatically so you don’t end up with a cluttered folder. | |
6. **Output**: The app displays the predicted speaker ID and confidence percentage. | |
--- | |
## 📦 Requirements | |
- **Python 3.8+** | |
- **yt-dlp** (installed automatically by the script if missing) | |
- **ffmpeg** (must be installed on your system and accessible via your command line) | |
- **gradio** (for the web interface) | |
- **transformers** (Hugging Face library) | |
> ❗ **Note**: If `yt-dlp` is not already installed, the code will install it at runtime. However, you must have `ffmpeg` installed manually. On macOS you can use Homebrew (`brew install ffmpeg`); on Ubuntu/Debian, `sudo apt-get install ffmpeg`; on Windows, download from [ffmpeg.org](https://ffmpeg.org/) and add it to your PATH. | |
--- | |
## 🚀 Installation | |
1. **Clone or Download** this repository (the one containing `app.py` and this `README.md`). | |
2. **(Optional)** Create and activate a virtual environment: | |
```bash | |
python3 -m venv venv | |
source venv/bin/activate # macOS/Linux | |
venv\Scripts\activate.bat # Windows | |