Giter Site home page Giter Site logo

maanavkhaitan / spotify-discover-together Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arjunrreddy/spotify-discover-together

0.0 1.0 0.0 14.42 MB

Choose a friend to discover brand new music with. We create an adventurous playlist curated to both of your tastes.

Jupyter Notebook 99.29% Python 0.71%

spotify-discover-together's Introduction

Spotify-Discover-2gether

Choose a friend to discover brand new music with. We create an adventurous playlist curated to both of your tastes.

Goal

Trustin and I analyzed and synthesize 2 users' Spotify recent taste profiles so that we can create a playlist filled with brand new song recommendations for both of them to discover together. The playlist we curate will automatically end up in both of their spotify libraries. A novel way for people to socialize because the playlist is unique to them and can create a special experience for both to find new music together that matches their music tastes.

Data Collection

We used Spotipy, a lightweight Python library for the Spotify Web API and created a Spotify Developers app to gain authorization to Spotify profile data. Here is the official Spotipy documentation: https://spotipy.readthedocs.io/en/2.13.0/

Also forked authorization flow codes from Plegas Gerasimos's repo that contained the codes for granting authorization flows which can be found here: https://github.com/makispl/Spotify-Data-Analysis

Then we created a code that authorizes access to a user's Spotify profile to extract their top 50 medium term songs using Spotipy's current_user_top_tracks() function. medium_term was the most optimal time frame since short_term songs were too short (~1 week of songs) and long_term was too long (basically a user's all time song history). The user's top 50 medium term songs were then extracted into a csv file, and this was repeated for the second user.

Clustering

Now that we had both users' top 50 songs, we can use those tracks for reference to recommend new songs that are curated for both people's recent music tastes. K-means clustering was the method we chose so that we could group each song from our combined songs into a cluster (sub-genre/type of song) regarding their sonic features that are officially provided by Spotify. These features include: danceability, energy, key (musical key), loudness, mode (minor or major), speechiness, acousticness, instrumentalness, liveness, valence (how positive/happy/cheerful it sounds), and tempo. We chose to focus on danceability, energy, speechiness, acousticness, valence, and tempo after concluding the other features were noise to our analysis. We also chose to have k=20 even though the elbow method showed that optimal k=6 since we wanted to have more specified clusters so that we could base our recommended songs off less generalized clusters.

Building the Playlist Creator

Once we got a list of songs for each cluster, we fed each list into Spotipy's recommendation() function which takes in 5 seed tracks to base its recommendation from. For the clusters that contained more than 5 songs, we randomly chose 5 from its list to represent the cluster. The clusters that contained less than 5 songs, we left it as is. We ran the recommendation function for each cluster, and each time it produced 1 recommended track for the clusters that contained less than 5 songs and 2 recommended tracks for the clusters that contained 5 songs. We wanted to put more weight onto the clusters with more songs since that meant we generally enjoyed songs that fit in those clusters moreso than the smaller clusters. After fetching all the recommended tracks, we put it into a list and called another Spotipy function that automatically creates and places a playlist with a given list of songs straight to the user's Spotify library.

Conclusion

Trustin and I found songs in the playlist that we both enjoyed and we thought matched both of our tastes in music. Trustin and I had commonalities in rap and electronic music and our algorithm was able to find the overlap in the subgenres within those that we enjoyed and found songs that were similar. Overall, our project was a success, and going forward we are looking to develop this idea into a functioning web app that anyone and their friend can use to find music together.

spotify-discover-together's People

Contributors

trustinyoon avatar arjunrreddy avatar noeltimothy avatar makispl avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.