Skip to content

MayaGalili/spotifyAgent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spotify AI Agent

A simple AI agent that plays songs on Spotify using natural language commands and OpenAI's function calling.

Features

  • 🎵 Natural Language Control - Say "Play Bohemian Rhapsody" and it plays!
  • 🤖 OpenAI Function Calling - Uses modern AI to understand your requests
  • 🎧 Smart Device Detection - Plays on available devices or your computer
  • 🔍 Song Search - Finds songs by name, artist, or genre

Quick Start

1. Install Dependencies

# Using uv (recommended)
uv sync

# Or using pip
pip install -r requirements.txt

2. Set Up API Keys

Create a .env file with your credentials:

SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret
SPOTIFY_URI=http://127.0.0.1:8888/callback
OPENAI_API_KEY=your_openai_api_key

3. Run the Agent

# Using uv (recommended)
uv run play_my_mode_agent.py

# Or using python directly
python play_my_mode_agent.py

4. Try Commands

  • "Play Bohemian Rhapsody"
  • "Play some jazz music"
  • "Play Imagine by John Lennon"

Requirements

  • Python 3.12+
  • Spotify account and developer credentials
  • OpenAI API key
  • Spotify app open on your computer

How It Works

  1. User Input: Natural language like "Play Bohemian Rhapsody"
  2. AI Analysis: OpenAI determines this needs the play_song function
  3. Function Call: Agent calls play_song("Bohemian Rhapsody")
  4. Spotify API: Searches and plays the song
  5. Response: Confirms what's playing

Setup Instructions

Get your API keys:

See SETUP.md for detailed instructions.

Troubleshooting

  • "No Spotify devices found" → Open Spotify on your computer
  • "Failed to get access token" → Check your .env file credentials
  • "OpenAI API Error" → Verify your OpenAI API key

License

MIT License - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages