Welcome to SpotifyAI! This repository documents the journey of building an autonomous AI Agent that can curate music based on your emotions. It evolves from simple scripts to a complex system integrating Spotify, OpenRouter (LLMs), and Hugging Face.
The project is split into 6 Learning Phases, designed to be explored in order:
| Phase | Folder | What You'll Learn |
|---|---|---|
| 01 | 01_Sentiment_Basics |
How to detect mood using simple keywords and text polarity. |
| 02 | 02_Spotify_Automation |
Interacting with the Spotify API to search tracks and create playlists. |
| 03 | 03_API_Experiments |
Basics of calling AI models (OpenAI/OpenRouter, Hugging Face). |
| 04 | 04_YouTube_Analysis |
Analyzing your YouTube liked videos to understand music taste. |
| 05 | 05_Local_LLM |
Running a privacy-focused local LLM (Ollama) as a music therapist. |
| 06 | 06_Final_Project |
The Final Agent: A complete system that detects mood and auto-generates playlists. |
Follow these steps to set up the project on your own machine.
git clone https://github.com/Swathi-88/SpotifyAI.git
cd SpotifyAIMake sure you have Python 3.8+ installed.
pip install -r requirements.txtFor security reasons, API keys are NOT included in this repository. You must create a configuration file locally to store your credentials.
-
Create a new folder named
configin the project root. -
Inside
config/, create a file namedsecrets.json. -
Paste the following JSON structure and fill in your keys:
{ "spotify_client_id": "YOUR_SPOTIFY_CLIENT_ID", "spotify_client_secret": "YOUR_SPOTIFY_CLIENT_SECRET", "spotify_redirect_uri": "http://127.0.0.1:8080", "openrouter_api_key": "YOUR_OPENROUTER_KEY", "huggingface_api_key": "YOUR_HF_TOKEN" }(Note: The
config/folder is git-ignored, so your keys will stay safe on your machine.)
If you want to run Phase 4 (YouTube Analysis):
- Download your OAuth 2.0 Client Secret JSON from Google Cloud Console.
- Rename it to
google_client_secret.json. - Place it inside the
config/folder.
python 06_Final_Project/spotify_ai_agent.pyFollow the on-screen prompts to tell the AI how you feel!
You can run any script from the earlier phases to test specific features:
# Example: Check your recently played songs on Spotify
python 02_Spotify_Automation/01_recently_played.py- Python
- Spotipy (Spotify Web API)
- OpenAI / OpenRouter (LLM for recommendations)
- Hugging Face (Emotion detection models)
- TextBlob (Sentiment analysis)
Created by Swathi-88.