Perfect Playlists is a website that contains AI-generated playlists, based on the top 250 user-generated playlists in Spotify for that genre. The playlists were made using the MATLAB Deep Learning Toolbox.
- MATLAB - to prepare the data for the model, create and train the model, and generate new playlists
- Python - to gather playlist and track data, clean data for the model, and to generate usable track URIs
- React - to create the web app that displays all the playlists
- Spotify API and Web Console - to get the playlist and track data and to make the playlists
By modifying an character-based LSTM RNN to run on Spotify track ids, I created a MATLAB model that learns the most common tracks as well as the sequencing of playlists to generate new playlists that have the best parts of all user-generated ones.
- Start by downloading all the requirements. Preferably, do this in a virtual env.
pip install -r requirements.txt
- Create an account to access the Spotify API. You'll also need to create an app and put the Client ID and Client Secret in a .env file.
- Change the query on line 30 of
getsongs.py
to whatever type of playlist you want to generate. Also, change line 28 to be however many playlists you want data from (times 50). Run the file withpython getsongs.py
. - Open
main_lstm_model.mlx
in MATLAB. Make sure that MATLAB is in the same folder as thetracks.csv
file. Change the file extension ontracks.csv
totracks.txt
. Run the MATLAB script, training for as long as you feel necessary. - Open
getUris.py
. Change lines 5 and 17 to the file names that are appropriate for your playlists. - On Spotify, create a playlist and get the playlist ID.
- Open the file with the track URIs. Also, open the Spotify Web Console for Add Items to a Playlist. Generate a token and paste the playlist URI as well as the track URIs into the console. Run the console.
- Listen and enjoy your AI-generated playlist.
Note: the app folder contains the code for the web app only.