An AI-powered web application that detects user mood via text or voice input and recommends personalized songs using Spotify, YouTube, and lyrics analysis.
This project intelligently recommends music based on a user's emotional state. It leverages:
- Gemini AI for emotion detection (text/voice)
- Spotify and YouTube APIs for music discovery
- Genius/Gemini fallback for lyrics analysis
- Librosa for audio feature extraction
- SQLite for lightweight local storage
- 🎤 Dual-mode mood input (Text + Voice)
- 🤖 Gemini-powered mood analysis
- 🎶 Real-time music suggestions
- 🧠 Fallback lyrics + mood extraction via Gemini
- 📊 Tempo & key analysis with Librosa
- 💾 Database storage using SQLite
Category | Tools/APIs |
---|---|
Language | Python 3.x |
Backend | Flask |
AI/ML | Google Gemini, Librosa |
APIs | Spotify, YouTube Data API, Genius |
Frontend | HTML5, CSS3, JavaScript (Basic) |
Database | SQLite |
git clone https://github.com/sumannaidur/Emotion-Based-Music-Recommender.git
cd Emotion-Based-Music-Recommender
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Create a .env
file in the root directory with the following variables:
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
YOUTUBE_API_KEY=your_youtube_api_key
GEMINI_API_KEY_1=your_gemini_key
GEMINI_API_KEY_2=optional_secondary
GEMINI_API_KEY_3=optional_tertiary
Note: Use dotenv to securely load environment variables.
python app.py
Visit: http://localhost:5000
- Mood Detection: User inputs mood via text or voice
- AI Analysis: Gemini AI processes and categorizes emotions
- Music Matching: System searches Spotify/YouTube for mood-appropriate songs
- Lyrics Analysis: Fallback system analyzes song lyrics for emotional context
- Audio Features: Librosa extracts tempo, key, and other musical characteristics
- Recommendation: Personalized playlist generated based on detected mood
To run this project, you'll need API keys from:
- Spotify for Developers - Music streaming and metadata
- YouTube Data API - Video content and metadata
- Google Gemini API - AI-powered emotion detection
- Genius API - Lyrics fetching and analysis
Suman Naidu R, Yashaswini N P, Divya L
B.E. (Information Science), APS College of Engineering[2021-2025]
Contributions are welcome! For major changes, please open an issue first to discuss what you'd like to change.
- Fork the Project
- Create your Feature Branch
- Commit your Changes
- Push to the Branch
- Open a Pull Request
⭐ If you found this project helpful, please consider giving it a star!