This project uses Resemblyzer to analyze and compare voice samples from two sources:
- My Lunch Break YouTube channel narrator
- Bobo from Finding Bigfoot TV series
# 1. Navigate to project directory
cd ~/cv/voice-analysis
# 2. Run the setup script (installs everything)
./setup.sh
# 3. Restart shell or reload bashrc (if pipx was installed)
source ~/.bashrc
# 4. Activate virtual environment
source venv/bin/activate
# 5. Download and prepare audio samples (see sections below)
# 6. Run the analysis
python3 voice_compare.py
# 7. When done, deactivate virtual environment
deactivateWhen you return to work on this project:
# Navigate to project
cd ~/cv/voice-analysis
# Activate virtual environment
source venv/bin/activate
# Run your commands (download audio, run analysis, etc.)
python3 voice_compare.py
# Deactivate when done
deactivateThat's it! The virtual environment has all dependencies pre-installed.
Resemblyzer is a voice comparison tool that uses deep learning to generate "voice embeddings" - numerical representations of speaker characteristics. By comparing these embeddings, we can determine if two voice samples are from the same person.
- OS: Ubuntu 24.04 LTS (also works on WSL2)
- Python: 3.12+ with venv support
- Tools: pipx (for yt-dlp), ffmpeg, audacity (optional)
Run the automated setup script:
cd voice-analysis
./setup.shThe script will:
- Install pip3, python3-venv, python3-full
- Prompt to install pipx (recommended for yt-dlp)
- Prompt to install ffmpeg (for audio conversion)
- Prompt to install audacity (for editing clips)
- Prompt to install yt-dlp (for downloading YouTube audio)
- Create a Python virtual environment (
venv/) - Install all Python dependencies with correct versions
Ubuntu 24.04+ uses "externally-managed-environment" protection to prevent breaking system Python packages. A virtual environment:
- Isolates project dependencies
- Avoids system conflicts
- Is the recommended Python workflow
# Install system dependencies
sudo apt-get update
sudo apt-get install -y python3-pip python3-venv python3-full pipx ffmpeg audacity
# Set up pipx
pipx ensurepath
source ~/.bashrc
# Install yt-dlp via pipx (recommended)
pipx install yt-dlp
# Create virtual environment
python3 -m venv venv
# Activate virtual environment
source venv/bin/activate
# Install Python dependencies
pip install -r requirements.txtYou need two audio samples (10-30 seconds each):
audio_samples/my_lunch_break_sample.wavaudio_samples/bobo_sample.wav
# Make sure venv is NOT activated for downloading
deactivate
# Run the download helper
./download_audio.shFollow the prompts to download audio from YouTube.
# Download full video audio
yt-dlp -x --audio-format wav -o "full_audio.wav" [YOUTUBE_URL]
# Open in Audacity to extract 30-second clip
audacity full_audio.wav
# Export the clip as audio_samples/my_lunch_break_sample.wavWSL2 Note: Audacity won't play audio on WSL2, but you can still:
- See the waveform
- Select and edit clips
- Export to WAV format
Extract a specific time range from downloaded audio:
# Extract 30 seconds starting at 1 minute 23 seconds
ffmpeg -i full_audio.wav -ss 00:01:23 -t 00:00:30 -ar 16000 -ac 1 audio_samples/output.wav- Format: WAV preferred (MP3 also works)
- Duration: 10-30 seconds of continuous speech
- Content: Only the target speaker (minimal background noise/music)
- Quality: Similar recording quality between both samples
- Speech: Normal speaking pace (not shouting/whispering)
# Always activate virtual environment first
source venv/bin/activate
# Run the analysis
python3 voice_compare.py
# View the generated visualization
# (Copy to Windows if on WSL2, or use an image viewer)The script will:
- Load both audio samples
- Generate voice embeddings using Resemblyzer
- Calculate similarity score (0-1 scale)
- Display results with interpretation
- Generate a visualization saved as
voice_comparison.png
The similarity score ranges from 0 to 1:
| Score Range | Interpretation | Likely Same Speaker? |
|---|---|---|
| > 0.85 | Very high similarity | ✓ Yes |
| 0.75-0.85 | High similarity | Possibly |
| 0.65-0.75 | Moderate similarity | Probably not |
| < 0.65 | Low similarity | ✗ No |
From actual testing:
- My Lunch Break vs Bobo: 0.6693 (66.93%) - Moderate similarity, likely different speakers
- Recording quality and equipment
- Background noise levels
- Sample selection (different clips may give different scores)
- Speaking style in that particular clip
- Audio compression
Tip: Try multiple clips from each source to verify consistency.
- Preprocessing: Audio is converted to 16kHz mono WAV and cleaned
- Embedding Generation: Resemblyzer uses a deep neural network (based on GE2E) to convert speech into a 256-dimensional vector
- Similarity Calculation: Cosine similarity between the two embeddings measures how close they are
- Visualization: Shows the embedding values and their differences
============================================================
VOICE ANALYSIS: My Lunch Break vs Bobo
============================================================
Processing Sample 1: My Lunch Break narrator
Loading audio from: audio_samples/my_lunch_break_sample.wav
✓ Generated embedding (shape: (256,))
Processing Sample 2: Bobo (Finding Bigfoot)
Loading audio from: audio_samples/bobo_sample.wav
✓ Generated embedding (shape: (256,))
Calculating similarity...
============================================================
RESULTS
============================================================
Similarity Score: 0.6693
Percentage Match: 66.93%
INTERPRETATION: Moderate similarity - some vocal characteristics match
Note: Similarity scores above 0.75 typically indicate the same speaker,
while scores below 0.65 usually indicate different speakers.
============================================================
Generating visualization...
Visualization saved as 'voice_comparison.png'
Analysis complete!
# Make sure pipx path is in your shell
source ~/.bashrc
# Or install via pipx
pipx install yt-dlp
# Verify installation
yt-dlp --versionThe apt version of yt-dlp is outdated. Use pipx version:
sudo apt remove yt-dlp
pipx install yt-dlp
source ~/.bashrcVirtual environment not activated:
source venv/bin/activate
python3 voice_compare.pyWrong librosa version. The requirements.txt pins it correctly:
source venv/bin/activate
pip install 'librosa<0.10.0'This is expected. WSL2 doesn't have audio output by default. You can:
- Use the waveform visualization to select clips
- Export without hearing playback
- Or copy files to Windows and use Audacity on Windows
Convert to proper format:
ffmpeg -i input.mp3 -ar 16000 -ac 1 output.wav- Ensure samples have minimal background noise
- Try different clips from each source
- Verify you're comparing the right speakers
- Check audio quality is reasonable
- Try longer samples (20-30 seconds)
Resemblyzer uses a speaker verification model trained on thousands of speakers. It creates speaker embeddings that capture unique vocal characteristics:
- Pitch and tone
- Speaking rate and rhythm
- Accent and pronunciation patterns
- Vocal timbre and resonance
- Prosody and intonation
The model is based on the Generalized End-to-End (GE2E) loss function and is designed to be robust to different recording conditions.
- Resemblyzer: Voice embedding model
- librosa < 0.10.0: Audio processing (pinned version for compatibility)
- numpy, scipy: Numerical computations
- matplotlib: Visualization generation
- webrtcvad: Voice activity detection
voice-analysis/
├── audio_samples/ # Directory for audio files
│ ├── my_lunch_break_sample.wav
│ ├── bobo_sample.wav
│ └── README.md
├── venv/ # Virtual environment (created by setup)
├── voice_compare.py # Main analysis script
├── requirements.txt # Python dependencies (with version pins)
├── setup.sh # Automated setup script
├── download_audio.sh # Helper to download YouTube audio
├── .gitignore # Git ignore rules
├── README.md # This file
└── voice_comparison.png # Generated visualization (after running)
- Sample Selection: Choose clips where the speaker talks continuously for 20-30 seconds
- Clean Audio: Avoid music, overlapping voices, or heavy background noise
- Consistency: Use similar recording quality for both samples
- Multiple Tests: Try different clips to verify consistency
- Context: Remember that vocal characteristics can vary (tired, excited, etc.)
- Verify if two channels/shows use the same voice actor
- Compare audio from different sources
- Speaker identification research
- Voice forensics (educational purposes)
- Audio production and dubbing verification
- Audacity won't play audio but can edit and export
- Copy
voice_comparison.pngto Windows to view:/mnt/c/Users/YourName/Desktop/ - GPU acceleration (CUDA) may not work; CPU fallback is automatic
- All command-line tools work normally
- Python 3.12+ requires virtual environments (externally-managed-environment)
- Use pipx for installing Python CLI tools (like yt-dlp)
- The setup.sh script handles all Ubuntu 24.04 quirks automatically
This project is for educational and research purposes. Ensure you have permission to use any audio samples you analyze.
Quick Command Reference:
# Setup (first time)
./setup.sh
# Activate environment
source venv/bin/activate
# Download audio
./download_audio.sh
# Run analysis
python3 voice_compare.py
# Deactivate
deactivate