Skip to content

An autonomous AI Agent that detects your mood and curates personalized Spotify playlists using Large Language Models (LLMs) and Emotion Recognition. From basic scripts to a full-fledged AI music therapist.

Notifications You must be signed in to change notification settings

Swathi-88/SpotifyAI

Repository files navigation

SpotifyAI Project 🎵🤖

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.

� Project Structure

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.

🚀 Getting Started

Follow these steps to set up the project on your own machine.

1. Clone the Repository

git clone https://github.com/Swathi-88/SpotifyAI.git
cd SpotifyAI

2. Install Dependencies

Make sure you have Python 3.8+ installed.

pip install -r requirements.txt

3. 🔒 Configure Secrets (Important)

For security reasons, API keys are NOT included in this repository. You must create a configuration file locally to store your credentials.

  1. Create a new folder named config in the project root.

  2. Inside config/, create a file named secrets.json.

  3. 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.)

4. Optional: YouTube Setup

If you want to run Phase 4 (YouTube Analysis):

  1. Download your OAuth 2.0 Client Secret JSON from Google Cloud Console.
  2. Rename it to google_client_secret.json.
  3. Place it inside the config/ folder.

🏃‍♂️ How to Run

Run the Final AI Agent

python 06_Final_Project/spotify_ai_agent.py

Follow the on-screen prompts to tell the AI how you feel!

Run Individual Experiments

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

�️ Technologies Used

  • Python
  • Spotipy (Spotify Web API)
  • OpenAI / OpenRouter (LLM for recommendations)
  • Hugging Face (Emotion detection models)
  • TextBlob (Sentiment analysis)

Created by Swathi-88.

About

An autonomous AI Agent that detects your mood and curates personalized Spotify playlists using Large Language Models (LLMs) and Emotion Recognition. From basic scripts to a full-fledged AI music therapist.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages