This project is a song recommendation engine that utilizes the Spotify API and the K-nearest neighbors algorithm (KNN) to recommend similar songs based on the user's top tracks.
- Fetches the user's top tracks from their Spotify account.
- Extracts audio features of the user's top tracks using the Spotify API.
- Trains a KNN model using the extracted audio features.
- Fetches a song catalog playlist from Spotify.
- Calculates the similarity between the user's top tracks and songs in the catalog using the KNN model.
- Ranks and displays the top recommended songs.
- Create a Spotify Developer account and set up a new application to obtain the required client ID and client secret.
- Update the
client_id
andclient_secret
variables in the code with your own credentials. - Run the script and follow the authentication prompts to grant access to the Spotify API.
- Run the script using
python song-recommendation-engine.py
. - The script will retrieve your top tracks and calculate the most similar songs from the provided catalog playlist.
- The top recommended songs will be displayed in the console.
- You can modify the
limit
parameter when fetching the user's top tracks to specify the number of tracks to consider. - Update the
playlist_id
variable to target a different Spotify playlist for the song catalog.
This project is licensed under the MIT License.