A Streamlit application that uses OpenAI's gpt-4o and Spotify's API to create AI-powered mixtapes. The app leverages gpt-4o to intelligently select iconic moments from songs based on your prompts, then uses Spotify's API to create and play personalized medleys of these memorable segments.
The app uses OpenAI's gpt-4o model to generate personalized mixtapes:
-
When you enter a description (e.g., "Create a 5-minute mixtape of classic rock hits from the 70s, focusing on guitar solos"), the app sends this to OpenAI's API.
-
The AI model generates a structured JSON response containing:
- Mixtape title
- Total duration
- List of songs with:
- Song name
- Artist
- Start timestamp (MM:SS)
- Stop timestamp (MM:SS)
-
The AI is specifically instructed to:
- Choose the most iconic or memorable parts of songs
- Select segments between 20-60 seconds long
- Focus on memorable moments like choruses, guitar solos, or hooks
- Use accurate timestamps where these iconic moments occur
-
This generated playlist is then used to create a medley by playing the specified segments of each song through Spotify's API.
- Generate custom mixtapes based on text prompts
- Seamless integration with Spotify's playback features
- Real-time playlist creation and management
- Interactive web interface
- Python 3.8 or higher
- A Spotify Premium account
- Spotify Developer credentials (Client ID and Client Secret)
-
Clone this repository:
git clone https://github.com/yourusername/spotify-mixtape.git cd spotify-mixtape
-
Set up a Python virtual environment:
pyenv virtualenv spotify-mixtape pyenv activate spotify-mixtape
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a Spotify Developer Application:
- Go to Spotify Developer Dashboard
- Create a new application
- Note down your Client ID and Client Secret
- Add
http://localhost:8501
to your application's Redirect URIs
-
Create a
.env
file in the project root with the following content:# Spotify API Credentials SPOTIPY_CLIENT_ID=your_client_id_here SPOTIPY_CLIENT_SECRET=your_client_secret_here SPOTIPY_REDIRECT_URI=http://localhost:8501 # OpenAI API Key for mixtape generation OPENAI_API_KEY=your_openai_api_key_here # Weights & Biases API Key WANDB_API_KEY=your_wandb_api_key_here
-
Ensure your virtual environment is activated:
pyenv activate spotify-mixtape
-
Start the Streamlit application:
streamlit run app.py
-
Open your web browser and navigate to
http://localhost:8501
-
Log in with your Spotify account when prompted
- You must have an active Spotify Premium subscription to use playback features
- Make sure you have a Spotify-compatible device available for playback
- Keep your
.env
file secure and never commit it to version control
If you encounter any issues:
- Ensure all environment variables are properly set
- Check that your Spotify Premium subscription is active
- Verify that you have an active internet connection
- Make sure your Spotify device is available and ready for playback