An intelligent music recommendation system that analyzes your mood through natural language and suggests personalized playlists using advanced AI and machine learning techniques.
- Natural Language Processing: Describe your mood in plain English
- Multiple AI Methods:
- OpenAI GPT integration for advanced understanding
- NLTK VADER sentiment analysis
- Custom keyword-based detection
- Real-time Analysis: Instant mood classification with confidence scores
- AI-Enhanced Song Analysis: ChatGPT analyzes individual songs for mood compatibility
- Intelligent Song Selection: AI evaluates track characteristics beyond simple audio features
- Dual Recommendation Modes:
- Standard algorithmic matching
- Advanced AI-powered curation (with OpenAI API key)
- Personalized Explanations: Get detailed AI reasoning for each song recommendation
- Song Comparison: AI ranks multiple songs for specific moods
- Interactive Feedback: Rate recommendations to improve future suggestions
- Mood Distribution: Visualize your emotional patterns over time
- Music Feature Analysis: Understand the audio characteristics of your preferences
- Recommendation Insights: See why certain songs were suggested
- Interactive Charts: Explore your data with dynamic visualizations
- Realistic Music Library: 200+ carefully curated demo tracks across all genres
- Diverse Moods: Experience recommendations for happy, sad, energetic, calm, and more
- No Setup Required: Try all features immediately without any API keys
git clone https://github.com/djleamen/music-mood-matcher-demo
cd music-mood-matcher-demo
pip install -r requirements.txt
# Option 1: Direct launch
streamlit run demo.py
# Option 2: Using start script
chmod +x start_demo.sh
./start_demo.sh
Navigate to http://localhost:8501
to access the interactive demo.
- Python: 3.8 or higher
- Memory: 2GB RAM minimum
- Storage: 100MB for dependencies
- Browser: Any modern web browser
- Internet: Required for initial package installation
- Overview of the system capabilities
- Quick stats about the demo music library
- Navigation to different features
-
Enter Your Mood: Type how you're feeling in natural language
- Examples: "I need energizing music for my workout"
- "I want something chill for studying"
- "I'm feeling nostalgic and want emotional songs"
-
AI Analysis: Watch as the system:
- Analyzes your text for sentiment and keywords
- Determines your primary mood with confidence scores
- Maps your emotion to audio features
-
Get Recommendations: Receive a personalized playlist with:
- 20 carefully selected tracks
- Detailed explanations for each recommendation
- Audio feature visualizations
-
Provide Feedback: Rate songs to improve future recommendations
For enhanced mood detection using ChatGPT:
- Get an OpenAI API key from OpenAI Platform
- Copy
.env.example
to.env
- Add your API key:
OPENAI_API_KEY=your_api_key_here
Benefits of OpenAI Integration:
- More nuanced mood understanding
- Better handling of complex emotional descriptions
- Contextual reasoning for recommendations
- Improved accuracy for ambiguous inputs
musicanalyzer-demo/
โโโ demo.py # Main Streamlit application
โโโ core/ # Core AI modules
โ โโโ __init__.py
โ โโโ mood_analyzer.py # NLP and mood detection
โ โโโ music_analyzer.py # Audio feature analysis
โ โโโ recommendation.py # Recommendation engine
โโโ requirements.txt # Python dependencies
โโโ start_demo.sh # Launch script
โโโ .env.example # Environment template
โโโ README.md # This file
- NLTK VADER: Sentiment polarity analysis
- TextBlob: Additional sentiment processing
- OpenAI GPT: Advanced natural language understanding
- ChatGPT Song Analysis: Individual song evaluation for mood compatibility
- Intelligent Song Selection: AI considers track name, artist, and audio features
- Contextual Understanding: Incorporates user's specific mood description
- Comparative Ranking: AI compares multiple songs and ranks them for specific moods
- Detailed Explanations: Provides reasoning for each song recommendation
- Dual-Mode Operation: Seamlessly switches between AI and algorithmic approaches
- Enhanced Mood Detection: More accurate understanding of complex emotions
- Smart Song Curation: AI analyzes each song individually for optimal mood matching
- Personalized Explanations: Get detailed reasoning for why specific songs were chosen
- Song Comparison Tool: AI ranks multiple songs for any mood category
- Contextual Recommendations: AI considers your specific mood description when selecting music
- Audio Features: Analyzes danceability, energy, valence, tempo, etc.
- Clustering: Groups similar tracks using K-means
- Feature Scaling: Normalizes audio characteristics
- Correlation Analysis: Finds patterns in music preferences
- Cosine Similarity: Matches tracks to mood profiles
- Weighted Scoring: Balances multiple recommendation factors
- Diversity Injection: Ensures playlist variety
- Feedback Learning: Adapts to user preferences over time
- Text Processing: Clean and tokenize mood descriptions
- Feature Extraction: Convert text to numerical representations
- Mood Classification: Predict emotional state from input
- Audio Mapping: Match moods to musical characteristics
- Recommendation Scoring: Rank tracks by relevance
- Diversity Optimization: Select varied but relevant tracks
Try these example inputs to explore different features:
"I need high-energy music for an intense workout session"
Expected Output: High-energy electronic, rock, and hip-hop tracks
"I want calm, instrumental music for deep concentration"
Expected Output: Ambient, classical, and lo-fi tracks
"I'm going through a breakup and need songs that understand my pain"
Expected Output: Emotional ballads and introspective tracks
"I'm hosting a party and need upbeat danceable music"
Expected Output: Pop, dance, and party classics
"It's 2 AM and I want something dreamy and atmospheric"
Expected Output: Chillout, downtempo, and atmospheric tracks
# If you see module import errors
pip install --upgrade -r requirements.txt
import nltk
nltk.download('vader_lexicon')
nltk.download('punkt')
# Use a different port
streamlit run demo.py --server.port 8502
- Verify your API key is correct
- Check your OpenAI account has credits
- Demo works without OpenAI if key is invalid
- Large Playlists: Reduce playlist size for faster generation
- Slow Loading: Restart the demo if it becomes unresponsive
- Memory Usage: Close other applications if system is slow
- Real Spotify Integration: Connect to your actual music library
- Voice Input: Speak your mood instead of typing
- Multiple Languages: Support for non-English mood descriptions
- Social Features: Share playlists and mood insights
- Smart Scheduling: Automatic mood detection based on time/calendar
- Deep Learning: Neural networks for better mood understanding
- Real-time Audio: Analyze currently playing music
- Collaborative Filtering: Learn from community preferences
- Cross-platform: Desktop and mobile applications
- Natural Language Processing: Text analysis and sentiment detection
- Machine Learning: Classification and recommendation algorithms
- Data Science: Feature engineering and statistical analysis
- Web Development: Interactive application design
- Python: Core programming language
- Streamlit: Web application framework
- Scikit-learn: Machine learning library
- NLTK: Natural language processing
- Plotly: Interactive data visualization
- OpenAI: Advanced AI integration
This is a demo project, but you can extend it:
- Fork the repository
- Add new mood categories
- Improve recommendation algorithms
- Enhance the user interface
- Add new visualization types
This demo is provided for educational and demonstration purposes.
- OpenAI: GPT integration for advanced NLP
- Spotify: Audio feature definitions and inspiration
- Streamlit: Excellent web framework for ML demos
- NLTK: Robust natural language processing tools
- Scikit-learn: Comprehensive machine learning library
๐ต Ready to explore your musical emotions? Launch the demo and discover how AI can understand your mood through music!
streamlit run demo.py