Machine learning project for classifying EDM subgenres using audio feature extraction and HistGradientBoostingClassifier.
This system analyzes audio files and predicts their EDM subgenre with high accuracy (90%+). Supports 4 EDM subgenres: Drum & Bass, Eurobeat, House, and Trance.
- 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
./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
pip install -r requirements.txtOr install manually:
pip install librosa numpy pandas scikit-learn natsort beautifulsoup4 requests matplotlib joblib streamlitpython scraper.pypython downloader.pyExtract acoustic features from all audio samples:
python extraction.pyNote: This process takes several hours for large datasets (4,000+ files).
Train the HistGradientBoostingClassifier:
python training.pyThis generates:
model.pkl- Trained classifierscaler.pkl- Feature scalerlabel_encoder.pkl- Genre label encoder
python -m streamlit run app.pyOpen your browser to http://localhost:8501
- Click "Browse files" button
- Upload an MP3 or WAV file
- Wait for analysis (a few seconds)
- View predicted genre and confidence scores
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
- 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
- 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
- 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
- Ornie Payer
- Winson Li
- Russell Hu
- Expand to additional EDM subgenres
- Real-time audio stream classification
- Model performance visualization dashboard
- Batch file processing capability
- Export classification results to CSV
Educational project for CSE 368 course at University at Buffalo.