π§ AI-Powered Mood-Based Music Recommender A Python CLI app that analyzes your mood using NLTK's VADER sentiment analysis and recommends Spotify songs accordingly. Supports moods like happy, sad, relaxed, and angry. Built with Spotipy, NLTK, and AI tools.
π§ AI-Powered Mood-Based Music Recommendation A Python application that recommends Spotify songs based on the user's current mood. It uses NLTK's VADER sentiment analysis to detect mood from text input and fetches songs from Spotify playlists aligned with different emotional states.
π Features π Mood Detection using natural language input.
π΅ Spotify API Integration to fetch real-time music recommendations.
π Supports moods: happy, sad, relaxed (add angry if you enhance mood detection).
π» Lightweight Command-Line Interface.
π§ Built with the help of AI tools like ChatGPT and Blackbox AI.
π οΈ Setup Instructions
- Prerequisites Python 3.6 or higher.
Spotify Developer Account to obtain Client ID and Client Secret.
Internet connection (for Spotify API and downloading NLTK data).
- Clone the Repository
git clone cd
- Install Required Packages
pip install spotipy nltk 4. Configure Spotify Credentials You need to set your Spotify credentials as environment variables.
On Windows (Command Prompt or PowerShell):
set SPOTIPY_CLIENT_ID=your_spotify_client_id set SPOTIPY_CLIENT_SECRET=your_spotify_client_secret
On macOS/Linux (Terminal):
export SPOTIPY_CLIENT_ID=your_spotify_client_id export SPOTIPY_CLIENT_SECRET=your_spotify_client_secret π‘ Tip: You can also store credentials in a .env file using python-dotenv for development, but avoid committing this file.
- Download NLTK VADER Lexicon This happens automatically the first time, but you can also do it manually:
python
import nltk
nltk.download('vader_lexicon')
python main.py You will be prompted:
sql
How are you feeling today? Type in a sentence describing your mood, for example:
rust
I'm feeling super excited and energized today! The app will analyze your mood and print a list of recommended Spotify songs.
π Project Structure mood-music-recommender/ βββ src/ β βββ mood_music_recommender/ β βββ init.py β βββ main.py β βββ mood_detection.py β βββ music_recommendation.py β βββ spotify_auth.py β βββ config.py βββ .gitignore βββ requirements.txt βββ setup.py βββ LICENSE βββ README.md βββ runtime.txt
π΅ Playlist Mapping Update music_recommendation.py with your own Spotify playlist IDs:
python
mood_playlists = { 'happy': 'your_playlist_id', 'sad': 'your_playlist_id', 'relaxed': 'your_playlist_id', 'angry': 'your_playlist_id' } π Security Notes Do NOT commit your Client ID and Client Secret to public repositories.
Use .env or environment variables instead of hardcoding credentials in config.py.
π License This project is licensed under the MIT License. See the LICENSE file for more details.
π€ Contributing Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
π¬ Contact For feedback, questions, or collaborations, contact: [Your Email or GitHub Profile]
π Acknowledgements NLTK β Natural Language Toolkit
Spotipy β Lightweight Python library for the Spotify Web API