Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/szilvia-csernus/spotify-playlist-generator
Playlist generator project using OpenAI's GPT models and the Spotify API.
https://github.com/szilvia-csernus/spotify-playlist-generator
Last synced: 1 day ago
JSON representation
Playlist generator project using OpenAI's GPT models and the Spotify API.
- Host: GitHub
- URL: https://github.com/szilvia-csernus/spotify-playlist-generator
- Owner: szilvia-csernus
- Created: 2024-05-31T10:49:35.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2024-06-04T08:32:35.000Z (5 months ago)
- Last Synced: 2024-06-04T09:51:08.317Z (5 months ago)
- Language: Python
- Size: 690 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spotify Playlist Generator
Music Playlist Generator, using the OpenAI API and the Spotify API. A single line of command generates a playlist on the connected Spotify account.
Example command: `python app.py -p "Rainy Days" -n 10 -m "gpt-4o"`
Arguments:
* `-p` - Prompt for the OpenAI LLM to create a playlist. Used as the name of the playlist as well.
* `-n` (optional) - Number of songs to be listed. Default number: 8
* `-m` (optional) - Name of the Large Language Model. Default is `gpt-3.5-turbo`.![playlist](playlist.jpeg)
## How to run this project?
0. Prerequisites:
- Make sure Python3 is installed.
- If you don't have an account with OpenAI, create one here: https://openai.com/
- Create a project API key under Dashboard / API keys
- Create a Spotify Developer Account here: https://developer.spotify.com1. Clone the project.
2. Create a virtual environment inside the project folder:
`python -m venv venv`
3. Activate the virtual environment:
Mac: `source venv/bin/activate`
Windows: `venv\Scripts\activate`
4. Create an `.env` file in the root folder and add your project's API key:
```
OPENAI_API_KEY=your-unique-opanai-project-key
SPOTIFY_CLIENT_ID=your-unique-client-ID
SPOTIFY_CLIENT_SECRET=your-unique-client-secret
```5. Install the python dependencies:
`pip install -r requirements.txt`
6. Create an "app" on Spotify
Under Spotify's Developer Dashboard, create a new App: Give it a name, description, and a redirect URI: http://localhost:9999
7. Run the project in the console:
- `python app.py -p "Happy days"` - "Happy days" will be the prompt for OpenAI to generate the playlist and it will be the title of the playlist on Spotify also.
- `python app.py -p "Happy days" -n 10 -m "gpt-4o"` - The playlist is generated with the "gpt-4o" model and will consist of 10 sound tracks.
- Command line arguments:
* `-p` - Prompt for the OpenAI LLM to create a playlist. Used as the name of the playlist as well.
* `-n` (optional) - Number of songs to be listed. Default number: 8
* `-m` (optional) - Name of the Large Language Model. Default is `gpt-3.5-turbo`.## Credits
This project was adopted from Colt Steele's Walkthrough project on Udemy: [Mastering OpenAI Python APIs](https://www.udemy.com/course/mastering-openai/?couponCode=24T3MT53024).
Changes made: API calls have been updated as per the latest documentation.