Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voice Analysis Project: My Lunch Break vs Bobo

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

Quick Start (One-Shot Setup)

# 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
deactivate

Coming Back to This Project

When 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
deactivate

That's it! The virtual environment has all dependencies pre-installed.

Overview

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.

System Requirements

  • OS: Ubuntu 24.04 LTS (also works on WSL2)
  • Python: 3.12+ with venv support
  • Tools: pipx (for yt-dlp), ffmpeg, audacity (optional)

Detailed Setup

One-Time Setup

Run the automated setup script:

cd voice-analysis
./setup.sh

The script will:

  1. Install pip3, python3-venv, python3-full
  2. Prompt to install pipx (recommended for yt-dlp)
  3. Prompt to install ffmpeg (for audio conversion)
  4. Prompt to install audacity (for editing clips)
  5. Prompt to install yt-dlp (for downloading YouTube audio)
  6. Create a Python virtual environment (venv/)
  7. Install all Python dependencies with correct versions

Why Virtual Environment?

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

Manual Setup (if needed)

# 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.txt

Obtaining Audio Samples

You need two audio samples (10-30 seconds each):

  • audio_samples/my_lunch_break_sample.wav
  • audio_samples/bobo_sample.wav

Method 1: Using the Helper Script

# Make sure venv is NOT activated for downloading
deactivate

# Run the download helper
./download_audio.sh

Follow the prompts to download audio from YouTube.

Method 2: Manual Download

# 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.wav

WSL2 Note: Audacity won't play audio on WSL2, but you can still:

  • See the waveform
  • Select and edit clips
  • Export to WAV format

Method 3: Using ffmpeg

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

Audio Sample Requirements

  • 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)

Usage

# 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:

  1. Load both audio samples
  2. Generate voice embeddings using Resemblyzer
  3. Calculate similarity score (0-1 scale)
  4. Display results with interpretation
  5. Generate a visualization saved as voice_comparison.png

Understanding Results

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

Example Results

From actual testing:

  • My Lunch Break vs Bobo: 0.6693 (66.93%) - Moderate similarity, likely different speakers

Factors Affecting Results

  • 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.

How It Works

  1. Preprocessing: Audio is converted to 16kHz mono WAV and cleaned
  2. Embedding Generation: Resemblyzer uses a deep neural network (based on GE2E) to convert speech into a 256-dimensional vector
  3. Similarity Calculation: Cosine similarity between the two embeddings measures how close they are
  4. Visualization: Shows the embedding values and their differences

Example Output

============================================================
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!

Troubleshooting

yt-dlp: Command Not Found

# Make sure pipx path is in your shell
source ~/.bashrc

# Or install via pipx
pipx install yt-dlp

# Verify installation
yt-dlp --version

yt-dlp: HTTP Error 403 Forbidden

The apt version of yt-dlp is outdated. Use pipx version:

sudo apt remove yt-dlp
pipx install yt-dlp
source ~/.bashrc

ModuleNotFoundError: No module named 'numpy'

Virtual environment not activated:

source venv/bin/activate
python3 voice_compare.py

TypeError: resample() takes 1 positional argument but 3 were given

Wrong librosa version. The requirements.txt pins it correctly:

source venv/bin/activate
pip install 'librosa<0.10.0'

Audacity Won't Play Audio on WSL2

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

Audio Format Issues

Convert to proper format:

ffmpeg -i input.mp3 -ar 16000 -ac 1 output.wav

Poor Results / Unexpected Scores

  • 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)

Technical Details

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.

Key Dependencies

  • 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

Project Structure

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)

Tips for Best Results

  1. Sample Selection: Choose clips where the speaker talks continuously for 20-30 seconds
  2. Clean Audio: Avoid music, overlapping voices, or heavy background noise
  3. Consistency: Use similar recording quality for both samples
  4. Multiple Tests: Try different clips to verify consistency
  5. Context: Remember that vocal characteristics can vary (tired, excited, etc.)

Common Use Cases

  • 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

WSL2-Specific Notes

  • Audacity won't play audio but can edit and export
  • Copy voice_comparison.png to Windows to view: /mnt/c/Users/YourName/Desktop/
  • GPU acceleration (CUDA) may not work; CPU fallback is automatic
  • All command-line tools work normally

Ubuntu 24.04-Specific Notes

  • 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

References

License

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

About

Voice comparison tool using Resemblyzer to analyze speaker similarity

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages