Skip to content

ESHAYAY/Music-Genre-Classifier

Repository files navigation

🎡 AI Music Genre Classifier

A sophisticated web application that uses machine learning to classify music genres from audio files with 73% accuracy. Features comprehensive audio analysis, real-time visualizations, and multiple music processing tools.

Music Genre Classifier Python Flask

✨ Features

🎯 Core Functionality

  • Genre Classification: ML model with 73% accuracy across 10 genres
  • Real Audio Analysis: MFCC, spectral, and temporal feature extraction
  • Confidence Scoring: Detailed probability breakdowns with uncertainty detection

🎨 Visualization & Analysis

  • Real-time Audio Visualizations: Waveform, spectrum, MFCC, and time-domain graphs
  • Interactive Audio Player: Vinyl-style player with equalizer
  • Feature Extraction: Tempo, key, energy, spectral centroid, and more

⚑ Advanced Tools

  • Batch Processing: Upload and analyze multiple files simultaneously
  • Audio Mashup Mixer: Blend two tracks with adjustable parameters
  • Music Visualizer: Real-time animated visualizations
  • Audio Comparison: Side-by-side track analysis with similarity scoring

πŸ“Š Export & Sharing

  • Multiple Formats: JSON, CSV, PDF, and text reports
  • Batch Export: Comprehensive results for multiple files
  • Shareable Results: Clipboard copy and social sharing
image image

🎼 Supported Genres

  • Blues 🎸
  • Classical 🎻
  • Country 🀠
  • Disco πŸ’ƒ
  • Hiphop 🎀
  • Jazz 🎷
  • Metal 🀘
  • Pop 🎀
  • Reggae 🌴
  • Rock 🎸
image

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • Modern web browser with Web Audio API support

Installation

  1. Clone the repository
    git clone https://github.com/yourusername/music-genre-classifier.git
    cd music-genre-classifier
  2. Install Python dependencies
    pip install -r requirements.txt
  3. Train the model (optional - pre-trained model included)
    python train_model_v2.py
  4. Start the Flask server
    python app.py
  5. Open your browser
    http://localhost:5000
    

πŸ› οΈ Technical Stack

Backend

  • Flask: Web framework and API
  • Scikit-learn: Machine learning (Random Forest + Gradient Boosting ensemble)
  • Librosa: Audio feature extraction
  • NumPy/SciPy: Scientific computing

Frontend

  • Vanilla JavaScript: Modern ES6+ features
  • Web Audio API: Real-time audio processing
  • Canvas API: Dynamic visualizations
  • Tailwind CSS: Responsive styling

Audio Processing

  • MFCC Analysis: 13 coefficients with statistical features
  • Spectral Features: Centroid, rolloff, bandwidth, contrast
  • Temporal Features: Tempo, zero-crossing rate, RMS energy
  • Harmonic/Percussive: Source separation analysis
image

music-genre-classifier/ β”œβ”€β”€ app.py # Flask backend server β”œβ”€β”€ train_model.py # Original model training β”œβ”€β”€ train_model_v2.py # Improved ensemble model β”œβ”€β”€ debug_model.py # Model debugging and testing β”œβ”€β”€ models/ # Trained model files β”œβ”€β”€ static/ β”‚ β”œβ”€β”€ script.js # Main application logic β”‚ β”œβ”€β”€ real-audio-visualizer.js # Audio visualization β”‚ β”œβ”€β”€ batch-processor.js # Batch upload system β”‚ β”œβ”€β”€ export-manager.js # Export functionality β”‚ └── keyboard-shortcuts.js # UX enhancements β”œβ”€β”€ templates/ β”‚ └── index.html # Main interface └── requirements.txt # Python dependencies

🎹 Usage

Single File Analysis

  • Drag & drop an audio file (MP3/WAV, up to 50MB)
  • View real-time analysis with interactive visualizations
  • Explore genre prediction with confidence scores
  • Export results in multiple formats

Batch Processing

  • Upload multiple audio files
  • Monitor progress with live updates
  • View aggregated statistics and genre distribution
  • Export comprehensive batch reports

Audio Tools

  • Mashup Mixer: Combine two tracks with volume control and crossfade
  • Music Visualizer: Real-time animated spectrum displays
  • Audio Comparison: Compare tracks with similarity scoring

πŸ”§ API Endpoints

  • POST /api/classify - Analyze single audio file
  • GET /api/health - Server status check
  • GET /api/genres - List supported genres

πŸ“ˆ Model Performance

  • Accuracy - 73% (improved ensemble model)
  • Featurea - 43 audio characteristics per sample
  • Genres - 10 distinct music categories
  • Processing - ~2-10 seconds per file (depending on size)

🌟 Key Features

Smart Confidence Handling

  • Automatic uncertainty detection for low-confidence predictions
  • Alternative genre suggestions with probabilities
  • Visual indicators for prediction reliability

Professional Visualizations

  • Real waveform rendering from audio buffer data
  • Interactive frequency spectrum analysis
  • MFCC coefficient displays
  • Beat detection and tempo visualization

Enterprise-Grade Tools

  • Concurrent batch processing with progress tracking
  • Comprehensive export system (JSON, CSV, PDF, text)
  • Responsive design for all devices
  • Keyboard shortcuts for power users
image

🀝 Contributing

We welcome contributions! Please feel free to submit pull requests, report bugs, or suggest new features.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • GTZAN Dataset for genre classification benchmarks
  • Librosa library for audio feature extraction
  • Web Audio API for browser-based audio processing

About

Music Genre Classifier - ML-powered web app that analyzes audio files to detect music genres with 73% accuracy. Features real-time visualizations, batch processing, audio mashup, and comprehensive analysis tools. Built with Flask, Scikit-learn, and modern web technologies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors