Skip to content
 
 

Repository files navigation

EDM Genre Classifier

Machine learning project for classifying EDM subgenres using audio feature extraction and HistGradientBoostingClassifier.

Project Overview

This system analyzes audio files and predicts their EDM subgenre with high accuracy (90%+). Supports 4 EDM subgenres: Drum & Bass, Eurobeat, House, and Trance.

Features

  • Web scraping for music sample collection from Spotify playlists
  • Advanced audio feature extraction (17+ acoustic features)
  • Machine learning classification using HistGradientBoostingClassifier
  • Streamlit web interface for real-time genre prediction
  • Upload audio files and view predictions with confidence scores

Project Structure

./dataset/              # Audio samples organized by genre
  /dnb/                 # Drum & Bass tracks
  /eurobeat/            # Eurobeat tracks
  /house/               # House tracks
  /trance/              # Trance tracks
scraper.py              # Web scraping module for Spotify
downloader.py           # Audio file download script
extraction.py           # Feature extraction using Librosa
training.py             # Model training and evaluation
app.py                  # Streamlit web interface
requirements.txt        # Python dependencies

Installation

Install dependencies:

pip install -r requirements.txt

Or install manually:

pip install librosa numpy pandas scikit-learn natsort beautifulsoup4 requests matplotlib joblib streamlit

Usage

1. Data Collection (Optional - if starting from scratch)

Scrape music preview URLs:

python scraper.py

Download audio files:

python downloader.py

2. Feature Extraction

Extract acoustic features from all audio samples:

python extraction.py

Note: This process takes several hours for large datasets (4,000+ files).

3. Train Model

Train the HistGradientBoostingClassifier:

python training.py

This generates:

  • model.pkl - Trained classifier
  • scaler.pkl - Feature scaler
  • label_encoder.pkl - Genre label encoder

4. Launch Web Interface

python -m streamlit run app.py

Open your browser to http://localhost:8501

Web Interface Usage

  1. Click "Browse files" button
  2. Upload an MP3 or WAV file
  3. Wait for analysis (a few seconds)
  4. View predicted genre and confidence scores

Audio Features Extracted

The system extracts 17+ acoustic features from each audio sample:

  • MFCC (Mel-Frequency Cepstral Coefficients): Timbre and texture characteristics
  • Mel Spectrogram: Energy distribution across frequency bands
  • Chroma Features: Harmonic and tonal content
  • Spectral Centroid: Brightness of the sound
  • Spectral Bandwidth: Width of frequency distribution
  • Spectral Contrast: Difference between peaks and valleys in spectrum
  • Zero Crossing Rate: Noisiness and percussiveness detection
  • Tonnetz: Tonal space representation
  • BPM/Tempo: Rhythmic speed of the track

Model Performance

  • Algorithm: HistGradientBoostingClassifier
  • Target Accuracy: 90%+
  • Dataset Size: 4,000 audio samples (1,000 per genre)
  • Genres Supported: Drum & Bass, Eurobeat, House, Trance
  • Training/Test Split: 80/20

Project Timeline

  • Week 3: Data collection and web scraping implementation
  • Week 4: Feature extraction pipeline development
  • Week 5: Model training and evaluation
  • Week 6: Streamlit UI development and documentation

Technology Stack

  • Python 3.x
  • Librosa: Audio analysis and feature extraction
  • Scikit-learn: Machine learning and model training
  • Streamlit: Web interface framework
  • NumPy/Pandas: Data processing
  • BeautifulSoup: Web scraping
  • Joblib: Model serialization

Team

  • Ornie Payer
  • Winson Li
  • Russell Hu

Future Enhancements

  • Expand to additional EDM subgenres
  • Real-time audio stream classification
  • Model performance visualization dashboard
  • Batch file processing capability
  • Export classification results to CSV

License

Educational project for CSE 368 course at University at Buffalo.

About

Artificial Intelligence

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages