Madhav Nair, Bhuvan Hospet, Brianna Quinn
SpotiRecs is a full-stack web application that analyzes a user's inputed song(s) and recommends new songs that match the "vibe" using a machine learning model. Built with React, Flask, and the Spotify API.
This project provides a web interface to build custom albums based on user-selected songs. It uses K-Means clustering on audio features to find and rank songs that are sonically and stylistically similar.
The clustering engine:
- Identifies the cluster(s) your input songs belong to.
- Finds other songs in the same or related clusters.
- Ranks them by feature similarity to your input.
- Returns a playlist-like album of coherent, similar songs.
- Numerical:
danceability,energy,tempo,acousticness,valence - Categorical:
genre
- Python 3.6+
- Flask
- Pandas
- NumPy
- Scikit-learn
-
Install the required Python packages:
pip install flask flask-cors pandas numpy scikit-learn
-
Make sure the
trunc_songs.csvfile is in the root directory of the project.
Run the following command to start the server:
./run_album_builder.shOr manually:
python backend/register_cluster_api.py
python backend/server.pyOpen your web browser and navigate to:
- Main page:
http://localhost:5000/ - Album Builder:
http://localhost:5000/cluster_album
- Search for Songs: Enter a song title or artist name in the search box and click "Search".
- Select 3 Songs: Click "Select" next to the songs you want to include in your album. You must select exactly 3 songs.
- Build Your Album: Click "Build Album" to generate a personalized album based on your selected songs.
- Save Your Album: Click "Save Album" to save your album (placeholder functionality).
The clustering algorithm automatically determines the optimal number of clusters based on the dataset size. It uses a maximum of 20 clusters or 1 cluster per 50 songs, whichever is smaller.
If there aren't enough songs in the primary cluster, the algorithm will look for songs in nearby clusters to ensure a complete album.
The album builder provides the following API endpoints:
-
Search for songs:
GET /cluster_album/search_songs?query=<search_term>Returns a list of songs matching the search term.
-
Build an album:
POST /cluster_album/build_albumRequest body:
{ "song_indices": [123, 456, 789], "num_songs": 10 }Returns a list of songs that form the album.