Skip to content

1. Controller and Model

widepend edited this page Apr 19, 2021 · 90 revisions

Story Map

Story Map

Music Streaming

This app uses the Spotify API for Android. Spotify API allows us to not only get the publishment information about a song (title, artist, album, Spotify link, etc.), but also get calculated audio features, such as its danceability, energy, valence, and more.

Music Features & Analysis

This app uses the Spotify API to track and analyze the audio features of each song. The tracked features can be categorized as follows:

  • Mood: Danceability, Valence, Energy, Tempo
  • Properties: Loudness, Speechiness, Instrumentalness
  • Context: Liveness, Acousticness
  • Other In-depth Features: Segments, Tatums, Bars, Beats, Pitches, Timbre, and more

The major focus of our recommendation algorithm is to find songs with similar sentiments. When the recommender receives a song, it will run the music analysis on it and return other musical tracks with similar keys, BPM, and other user-specified features.

Recommendations

nearest_neighbors(initial_seed, initial_recs) link to source code

Takes in a dictionary of user-seeded song(s) and their associated metadata (initial_seed), as well as the candidate recommendations provided by the Spotify API (intial_recs). Takes the average for each factor for the input song(s) (initial_seed) and puts them into a vector to create our baseline. Then for all the songs in the initial_recs list takes their factors and puts them into a vector as well. Also tracks all meta data for each song in a tuple and matches it with its respective vector. For each song in the recommendation list (inital_recs) we compare their vector of factors with that of our baseline vector using cosine similarity. We then order them from highest to lowest cosine similarity. We then group the most similar songs together to be returned as the best recommendations.

playlist_rec_helper(seed_list) link to source code

Is called by the read_playlist endpoint in order to communicate with the Spotify API and process the output into a format that can be used by the nearest neighbor algorithm. The Spotify API returns a long complicated nested JSON structure that is hard to work with on its own, and thus must be processed by this function after the data is retrieved. The seed_list argument is a string containing a Spotify playlist ID.

track_rec_helper(seed_list) link to source code

Is called by the getsong endpoint in order to communicate with the Spotify API and process the output into a format that can be used by the nearest neighbor algorithm. The Spotify API returns a long complicated nested JSON structure that is hard to work with on its own, and thus must be processed by this function after the data is retrieved. The seed_list argument is a string containing a Spotify track ID.

Clone this wiki locally