Skip to content

Udhay-Brahmi/Emotion-based-music-recommendation-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

40 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 EmoNoteTunes

Emotion-Based Music Recommendation System

Transform your emotions into perfect music matches - Using AI to detect your feelings and recommend songs that resonate with your mood.


πŸ“Š Project Overview

EmoNoteTunes is an intelligent web-based application that combines computer vision and natural language processing to create personalized music recommendations based on your emotional state. By analyzing both facial expressions and text input, the system provides a sophisticated approach to music curation.

🎯 Key Statistics

  • 7 Emotion Categories Supported
  • 35+ Curated Songs Across All Emotions
  • 2-3 Second Processing Time
  • 30-40 Frames Analyzed for Accuracy
  • 48x48 Pixel Face Detection Resolution
  • 10 Recent Sessions Tracked

πŸš€ Features

πŸ” Dual Emotion Detection

  • πŸ“Έ Facial Emotion Recognition: Uses OpenCV and CNN models to detect emotions from webcam/uploaded images
  • πŸ“ Text Sentiment Analysis: Leverages TextBlob for natural language sentiment processing
  • πŸ€– Smart Fusion: Combines both inputs for enhanced accuracy

🎼 Intelligent Music Curation

  • 7 Emotion Categories: Happy, Sad, Angry, Neutral, Surprised, Fearful, Disgusted
  • Personalized Recommendations: 5 songs per emotion category
  • Dynamic Selection: Random sampling ensures variety in recommendations

πŸ’Ύ Session Management

  • SQLite Database: Persistent storage of user interactions
  • Session History: Track your last 10 emotion-music sessions
  • Analytics Ready: Timestamp and confidence tracking

πŸ› οΈ Technical Architecture

Core Components

  1. Computer Vision Pipeline

    Image Input β†’ Face Detection β†’ CNN Model β†’ Emotion Classification
    
  2. NLP Pipeline

    Text Input β†’ TextBlob Analysis β†’ Sentiment Scoring β†’ Emotion Mapping
    
  3. Recommendation Engine

    Combined Emotions β†’ Music Database β†’ Personalized Playlist
    

Machine Learning Models

  • CNN Architecture: 3 Convolutional layers + 2 Dense layers
  • Input Preprocessing: 48x48 grayscale normalization
  • Confidence Scoring: Softmax activation for emotion probabilities
  • Fallback System: Graceful degradation with random selection

πŸ“š Libraries & Dependencies

Library Version Purpose
Gradio Latest Modern web interface
OpenCV 4.x Computer vision & face detection
TensorFlow 2.x Deep learning framework
TextBlob Latest Natural language processing
NumPy Latest Numerical computations
Pandas Latest Data manipulation
SQLite3 Built-in Database operations

πŸš€ Quick Start Guide

1. Installation

# Clone the repository
git clone <repository-url>
cd EmoNoteTunes

# Install dependencies
pip install -r requirements.txt

2. Launch Application

# Start the Gradio interface
python app.py

3. Access the App

  • Local: http://localhost:7860
  • Share Link: Generated automatically for remote access

πŸ’‘ How It Works

Step-by-Step Process

  1. πŸ–ΌοΈ Image Capture

    • Upload photo or use live webcam
    • System detects faces using Haar Cascade
    • Extracts and processes 48x48 face regions
  2. 🧠 Emotion Analysis

    • CNN model predicts facial emotion (7 categories)
    • TextBlob analyzes text sentiment (-1 to +1 polarity)
    • Smart weighting combines both inputs
  3. 🎡 Music Recommendation

    • Maps final emotion to music database
    • Randomly selects 5 songs from emotion category
    • Displays personalized playlist
  4. πŸ’Ύ Session Storage

    • Saves interaction to SQLite database
    • Tracks timestamp, emotions, and recommendations
    • Enables history viewing and analytics

πŸ“ˆ Performance Metrics

Accuracy & Speed

  • Face Detection: >85% accuracy in good lighting
  • Processing Time: 2-3 seconds average
  • Model Confidence: 60-90% typical range
  • Text Sentiment: Real-time analysis

System Requirements

  • Memory: ~500MB RAM during operation
  • Storage: <100MB for application + model
  • CPU: Any modern processor (GPU optional)
  • Browser: Chrome, Firefox, Safari, Edge

🎨 User Interface

Modern Design Features

  • Responsive Layout: Works on desktop and mobile
  • Real-time Updates: Instant emotion detection
  • Interactive Elements: Webcam integration and file uploads
  • Session History: Track your emotional music journey
  • Tips & Guidance: Built-in usage instructions

Supported Inputs

  • Image Formats: JPG, PNG, BMP, TIFF
  • Camera Sources: Webcam, mobile camera
  • Text Input: Any natural language text
  • Session Tracking: Automatic history logging

πŸ—‚οΈ Project Structure

EmoNoteTunes/
β”œβ”€β”€ app.py                 # Main application file
β”œβ”€β”€ README.md             # Project documentation
β”œβ”€β”€ model.h5              # Pre-trained emotion model (optional)
β”œβ”€β”€ emotion_music.db      # SQLite database (auto-generated)
└── assets/               # Static files and resources

πŸ”§ Configuration Options

Emotion Thresholds

# Customize emotion detection sensitivity
FACE_CONFIDENCE_THRESHOLD = 0.7
TEXT_CONFIDENCE_THRESHOLD = 0.5
POLARITY_THRESHOLD = 0.1  # For text sentiment

Music Database

# Add custom songs to emotion categories
music_data = {
    'Happy': ['Your Custom Song - Artist'],
    'Sad': ['Another Song - Artist'],
    # ... customize as needed
}

πŸš€ Future Enhancements

Planned Features

  • Spotify Integration: Direct playlist creation
  • Voice Emotion Detection: Audio sentiment analysis
  • Group Sessions: Multi-user emotion analysis
  • ML Model Training: Custom model fine-tuning
  • Advanced Analytics: Emotion pattern tracking
  • Mobile App: Native iOS/Android versions

Technical Improvements

  • Model Optimization: Faster inference times
  • Cloud Deployment: Scalable web service
  • API Development: RESTful service endpoints
  • Real-time Streaming: Live emotion tracking

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages