An intelligent Spotify assistant that leverages OpenAI's GPT models to create personalized playlists and provide music recommendations through natural language conversations.
- AI-Powered Playlist Generation: Create custom playlists using natural language prompts
- Smart Music Recommendations: Get personalized song suggestions based on your listening history
- Conversational Interface: Chat with an AI assistant about music preferences and requests
- Spotify Integration: Seamless connection with your Spotify account
- User Analytics: View your top artists, tracks, and recently played music
- Modern Web Interface: Beautiful React-based UI with Material-UI components
Visit the application at: https://sutulas.github.io/Spotifhai/
Demo Credentials:
- Username:
sutulas@bc.edu - Password:
SpotifHAI1
- FastAPI - Modern Python web framework
- OpenAI GPT - AI-powered conversation and playlist generation
- Spotify Web API - Music data and playlist management
- Uvicorn - ASGI server
- React 18 - User interface framework
- Material-UI - Component library
- React Router - Client-side routing
- Axios - HTTP client
- Framer Motion - Animations
- Python 3.8+
- Node.js 16+
- Spotify Premium account
- OpenAI API key
git clone https://github.com/sutulas/Spotifhai.git
cd Spotifhai# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
# Set up environment variables
cp .env.example .env
# Edit .env with your API keyscd spotifhai
npm installCreate a .env file in the root directory:
OPENAI_API_KEY=your_openai_api_key_here
SPOTIFY_CLIENT_ID=your_spotify_client_id
SPOTIFY_CLIENT_SECRET=your_spotify_client_secret- Start the Backend Server
# From the root directory
python -m uvicorn main:app --reload- Start the Frontend Development Server
# From the spotifhai directory
npm startThe application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
# Build the frontend
cd spotifhai
npm run build
# Deploy to GitHub Pages
npm run deployPOST /generatePlaylists
Content-Type: application/json
{
"userId": "string",
"userPrompt": "string",
"accessToken": "string"
}POST /authCheck
Content-Type: application/json
{
"userId": "string",
"accessToken": "string"
}POST /recentlyListened
Content-Type: application/json
{
"userId": "string",
"accessToken": "string"
}POST /topArtists
Content-Type: application/json
{
"userId": "string",
"accessToken": "string",
"timeRange": "short_term|medium_term|long_term"
}- Connect your Spotify account
- Type a natural language prompt like:
- "Create a playlist for studying with ambient electronic music"
- "Make a workout playlist with high-energy rock songs"
- "Generate a chill playlist for rainy days"
- Ask about specific genres, moods, or activities
- Request songs similar to your favorite artists
- Get recommendations based on your listening history
The application uses Spotify OAuth 2.0 for authentication. Users need to:
- Log in with their Spotify account
- Grant permissions for playlist creation and profile access
- The app securely stores access tokens for API calls
- Natural Language Processing: Understand complex music requests
- Contextual Recommendations: Consider user preferences and history
- Playlist Optimization: Balance variety and cohesion in generated playlists
- Conversational Interface: Maintain context across multiple interactions
Spotifhai/
├── main.py # FastAPI backend server
├── playlistgen.py # Spotify playlist generation logic
├── requirements.txt # Python dependencies
├── spotifhai/ # React frontend application
│ ├── src/ # React source code
│ ├── public/ # Static assets
│ └── package.json # Node.js dependencies
├── auth_stuff/ # Authentication utilities
└── README.md # This file
- CORS Errors: Ensure the backend CORS settings match your frontend URL
- Spotify API Limits: Be aware of Spotify's rate limiting for API calls
- OpenAI API Errors: Check your API key and usage limits
- Authentication Issues: Verify Spotify app credentials and redirect URIs
# Enable debug logging
export DEBUG=1
python -m uvicorn main:app --reload --log-level debugNote: This application requires Spotify Premium for full functionality. Some features may be limited with free accounts.