An AI-powered music recommendation system that analyzes your mood through facial recognition and delivers personalized playlists
Demo β’ Features β’ Installation β’ Architecture β’ API Docs
MoodTunes AI is a full-stack web application that combines artificial intelligence, facial emotion recognition, and intelligent music recommendation algorithms to create personalized playlists based on your current emotional state. Using advanced APIs from Last.fm, YouTube, Google Gemini, and DeepGram, it delivers a seamless music discovery experience.
The heart of MoodTunes AI is its conversational AI chatbot powered by Google Gemini, featuring:
- π΅ Voice-Activated Music Control: Simply say "Play Kesariya" and watch it play instantly
- ποΈ Natural Language Commands:
- "Recommend songs by Arijit Singh for a romantic mood"
- "Play some happy Bollywood music"
- "Find songs similar to Tum Hi Ho"
- π Smart Song Search: Built-in search feature to discover and add songs to your favorites
- π¬ Conversational Recommendations: Chat naturally to get personalized music suggestions
- π Mood-Based Discovery: Ask for songs matching any emotion and get instant results
- π Real-time Mood Detection: Advanced facial recognition understands your emotions
- πΌ Smart Recommendations: Intelligent 4-category distribution algorithm
- π Bilingual Support: Enjoy both Hindi Bollywood and English Pop music
- π€ Voice-Controlled Chatbot: Play and discover music through natural conversation
- π Integrated Search: Find any song instantly with the search feature
- π¨ Beautiful Interface: Modern, responsive design with stunning animations
| Technology | Purpose | Version |
|---|---|---|
| UI Framework | 18.x | |
| Build Tool | 4.x | |
| CSS Framework | 3.x | |
| HTTP Client | Latest | |
| Animations | Latest |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β MOODTUNES AI β
β System Architecture β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β FRONTEND LAYER β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β React 18 + Vite + Tailwind CSS β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β β Mood β β Preference β β Music β β β
β β β Detection ββ β Selection ββ β Player β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β β Webcam β β Search β β Voice β β β
β β β Integrationβ β Component β β Chatbot β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ
β HTTP/REST API (Port 5173 β 8000)
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BACKEND API LAYER β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β FastAPI + Uvicorn (Port 8000) β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β β Mood β β Music β β Voice β β β
β β β Detection β β Search β β Chatbot β β β
β β β Endpoint β β Endpoint β β (Play/Rec) β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BUSINESS LOGIC LAYER β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Modular Components (modules/) β β
β β β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β recommendation_engine.py β β β
β β β ββββββββββββ ββββββββββββ ββββββββββββ β β β
β β β βCategory 1β βCategory 2β βCategory 3β β β β
β β β βArtist+ ββ βLanguage+ ββ βSimilar+ β β β β
β β β βMood+Lang β βMood (4) β βMood (4) β β β β
β β β β(8 songs) β β β β β β β β
β β β ββββββββββββ ββββββββββββ ββββββββββββ β β β
β β β β β β β
β β β ββββββββββββββββββββββββββββββββββββ β β β
β β β β Category 4: Fallback (4 songs) β β β β
β β β ββββββββββββββββββββββββββββββββββββ β β β
β β βββββββββββββββββββββββββββββββββββββββββββββββββββ β β
β β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β β β mood_ β β music_ β β voice_to_ β β β
β β β detection β β player.py β β text.py β β β
β β β (DeepFace) β β (YouTube) β β (DeepGram) β β β
β β ββββββββββββββ ββββββββββββββ ββββββββββββββ β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β EXTERNAL SERVICES β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β β Last.fm API β β YouTube API β β Gemini AI β β
β β (Music Data)β β (Playback) β β (Chatbot) β β
β ββββββββββββββββ ββββββββββββββββ ββββββββββββββββ β
β ββββββββββββββββ ββββββββββββββββ β
β β DeepFace Lib β β DeepGram API β β
β β (Mood Detect)β β (Voice->Text)β β
β ββββββββββββββββ ββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DATA FLOW DIAGRAM β
β β
β User β Camera β DeepFace β Mood Detection β
β β β
β User Voice β DeepGram β Text Transcription β
β β β
β Chatbot Processing: β
β β’ "Play [song]" β Direct playback β
β β’ "Recommend [mood/artist]" β Smart suggestions β
β β’ Natural conversation β Personalized responses β
β β β
β User Preferences (Language, Artists, Songs) β
β β β
β Music Search β Last.fm API β Add to Favorites β
β β β
β Recommendation Engine (4 Categories) β
β β β
β Last.fm API β Song Metadata β
β β β
β YouTube API β Video IDs β
β β β
β Frontend β Music Player β User β
β β β
β Voice Commands β Chatbot β Play/Recommend Actions β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Real-time facial emotion recognition using DeepFace library that identifies 6 emotional states:
- π Happy - Upbeat, energetic music
- π’ Sad - Melancholic, emotional songs
- π Calm - Peaceful, relaxing tracks
- π Angry - Intense, powerful music
- β€οΈ Romantic - Love songs and ballads
- β‘ Energetic - High-energy workout music
Our sophisticated 4-category distribution system creates perfect 20-song playlists:
| Category | Count | Description |
|---|---|---|
| Category 1 | 8 songs (40%) | Artist + Mood + Language matching |
| Category 2 | 4 songs (20%) | Language + Mood combinations |
| Category 3 | 4 songs (20%) | Similar to favorite songs + Mood |
| Category 4 | 4 songs (20%) | Intelligent fallback (language-based) |
- Hindi: Bollywood hits and classics
- English: Pop, Rock, and International tracks
Powered by Google Gemini AI for conversational music recommendations and queries.
Natural Language Commands:
- π΅ Direct Play: "Play Kesariya", "Play Shape of You"
- π€ Artist Requests: "Play songs by Arijit Singh", "Recommend AR Rahman tracks"
- π Mood-Based: "Play happy songs", "I want romantic music"
- π Combined Requests: "Recommend sad Bollywood songs by Shreya Ghoshal"
- π¬ Conversational: Chat naturally to get personalized suggestions
Real-time music search powered by Last.fm:
- Search any song or artist instantly
- Preview song details before adding
- One-click add to favorites
- Visual search results with artist info
- Seamless integration with recommendation engine
- Responsive design with Tailwind CSS
- Particle animations for immersive experience
- Embedded YouTube player with queue management
- Real-time webcam integration
MUSIC-REC/
βββ backend_modular/ # Backend API Service
β βββ modules/ # Core modules
β β βββ __init__.py # Module initialization
β β βββ config.py # API keys & service setup
β β βββ models.py # Pydantic data models
β β βββ mood_detection.py # Emotion recognition
β β βββ music_player.py # YouTube integration
β β βββ recommendation_engine.py # Smart algorithm
β β βββ voice_to_text.py # Speech recognition
β β βββ chatbot.py # Gemini AI integration
β βββ cache/ # API response cache
β βββ main.py # FastAPI application
β βββ requirements.txt # Python dependencies
β βββ .env # Environment variables
β βββ .env.example # Template for .env
β βββ start_backend.bat # Quick start script
β
βββ frontend/ # React Frontend
βββ src/
β βββ components/ # React components
β β βββ Chatbot.jsx # AI chat interface
β β βββ Header.jsx # Navigation bar
β β βββ Hero.jsx # Landing section
β β βββ MoodDetection.jsx # Camera + mood selector
β β βββ MusicPlayer.jsx # YouTube player
β β βββ Particles.jsx # Background animation
β β βββ PreferenceSelection.jsx # User preferences
β β βββ Recommendations.jsx # Song grid display
β β βββ StepCards.jsx # Navigation steps
β βββ App.jsx # Main application
β βββ main.jsx # Entry point
β βββ index.css # Global styles
βββ package.json # Node dependencies
βββ vite.config.js # Vite configuration
βββ tailwind.config.js # Tailwind setup
βββ start_frontend.bat # Quick start script
- Python 3.8+ for backend
- Node.js 16+ for frontend
- API Keys (free tiers available):
- Navigate to backend:
cd backend_modular- Create virtual environment:
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/Mac
source .venv/bin/activate- Install dependencies:
pip install -r requirements.txt- Configure environment:
# Copy .env.example to .env
cp .env.example .env
# Edit .env and add your API keysExample .env:
LASTFM_API_KEY=your_lastfm_key_here
LASTFM_API_SECRET=your_lastfm_secret_here
YOUTUBE_API_KEY=your_youtube_key_here
GEMINI_API_KEY=your_gemini_key_here
DEEPGRAM_API_KEY=your_deepgram_key_hereNote: DeepFace is automatically installed via requirements.txt (no API key needed)
- Start backend:
# Quick start
start_backend.bat
# Or manually
python main.pyβ Backend running at: http://localhost:8000
- Navigate to frontend:
cd frontend- Install dependencies:
npm install- Start development server:
# Quick start
start_frontend.bat
# Or manually
npm run devβ Frontend running at: http://localhost:5173
- Allow camera access for automatic mood detection
- Or manually select your current mood
- Click "Next" to proceed
- Select Language (Required): Hindi or English
- Add Favorite Artists (Optional): e.g., "Arijit Singh, AR Rahman"
- Add Favorite Songs (Optional): e.g., "Tum Hi Ho, Kesariya"
- Use Search Feature:
- Click search icon
- Type song or artist name
- Browse results and click to add to favorites
- Click "Get Personalized Recommendations"
- Browse 20 personalized song recommendations
- Click any song to play via YouTube player
- Use queue controls (Next/Previous)
- Use Voice Chatbot:
- Click chatbot icon (bottom right)
- Say: "Play Kesariya" β Instantly plays the song
- Say: "Recommend romantic songs by Shreya Ghoshal" β Get instant suggestions
- Say: "Search for happy Bollywood songs" β Get curated list
- Search for additional songs anytime using the search bar
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check |
POST |
/detect-mood |
Facial emotion detection |
POST |
/recommendations |
Basic mood recommendations |
POST |
/recommendations/personalized |
Smart personalized playlist |
GET |
/search-music |
Search songs by name/artist |
POST |
/chat |
Voice chatbot (play/recommend) |
GET |
/user/{user_id}/history |
User listening history |
Visit http://localhost:8000/docs for Swagger UI
Backend won't start:
- Verify all API keys in
.envfile - Check Python version (3.8+)
- Ensure port 8000 is available
- Install DeepFace dependencies:
pip install deepface tf-keras
DeepFace model download issues:
- First run downloads face detection models (~100MB)
- Ensure stable internet connection
- Models cached in
~/.deepface/weights/
Frontend CORS errors:
- Confirm backend is running on port 8000
- Check
vite.config.jsproxy settings
Camera not working:
- Grant browser camera permissions
- Use HTTPS or localhost
- Try manual mood selection as fallback
- Ensure good lighting for DeepFace detection
DeepGram transcription errors:
- Verify API key is valid
- Check microphone permissions
- Ensure clear audio input
YouTube quota exceeded:
- Daily limit: 10,000 units
- Each search costs 100 units
- Monitor usage in Google Cloud Console
Last.fm rate limits:
- Free tier: 60 requests/minute
- Consider implementing caching
DeepFace performance:
- First emotion detection may be slow (model loading)
- Subsequent detections are faster
- Use GPU for better performance (optional)
ML Engineer | AI/ML Enthusiast | Full Stack Developer
π BTech ECE @ IIIT Una
π‘ Passionate about AI/ML, GenAI, and Web Development
"Building intelligent applications that merge technology with creativity"
- π Currently working on AI-powered applications
- π± Exploring Generative AI and Deep Learning
- π» Full Stack Developer with expertise in React & FastAPI
- π΅ Music enthusiast combining tech with entertainment
- π« Reach me: abhishek.kr0418@gmail.com
AI/ML: TensorFlow, PyTorch, scikit-learn, DeepFace
Backend: Python, FastAPI, Uvicorn
Frontend: React, Tailwind CSS, JavaScript
APIs: Last.fm, YouTube, Gemini AI, DeepGram
Tools: Git, Docker, Vite
- DeepFace for facial emotion recognition
- DeepGram for voice transcription
- Last.fm for comprehensive music metadata
- Google Gemini AI for conversational AI
- YouTube for video playback
- FastAPI for excellent documentation
- React community for amazing resources
β Star this repo if you found it helpful!
Made with β€οΈ and π΅ by Kumar Abhishek
IIIT Una | BTech ECE