Inspiration

Our group wanted to address the issue of mental health that is prevalent in today’s younger generations. Many music enthusiasts form deep connections with their favorite songs and artists because of the emotional validation they feel. In fact, some may even call music their own therapy. In order to help users use music as a resource, we created a software program that provides recommendations based on their mood for songs that may help the user further.

What it does

From Billboard’s top 100 songs of 2022, the program searches for two key features of each song: energy and valence. Energy measures the perceptual intensity and activity, and valence measures the musical positiveness of each song. After obtaining the user’s mood on a numerical scale, it shuffles the playlist to select up to 5 songs uniformly at random that have energy and valence scores corresponding to the user’s mood score.

How it works

Using the Spotify API, we extract the audio features for every song from 2 megaplaylists: the “Billboard Hot 100” and the “Top 100 Most Streamed Songs on Spotify”. We pay particular attention to the energy and valence attributes of a given song to match the current mood of the user (prompted to be on a scale of 1-10). We then return a set of the 5 best songs from the playlist to the user that match their current state of mind and fall within the specified ranges that we designated in our script.

How we built it

The primary 2 tools we used to build this script involve Python and the Spotify API. We experimented with different audio features that would yield the best mood-based recommendations. We then created a list to which we appended songs that fell in the valence and energy ranges we specified for each respective mood range.

Challenges we ran into

Throughout the development of our program, we ran into quite a few problems. The first one being how to actually implement our idea. We knew we wanted to use the Spotify API but we were not sure exactly how to use it. As such, we had to look up the documentation of the API and also figure out what certain variables mean, for example we had to figure out what exactly valence measured and what energy was and so on. Another challenge we ran into was runtime. When searching for the right songs to fit the mood, we realized that it took almost 30 seconds for the code to fully run. From a user standpoint this would be extremely inefficient and would not be a very good program overall. Our solution was to cap the amount of songs by five so that the code does not keep searching after getting five songs, which lowered the runtime by a lot.

Accomplishments that we're proud of

Though we faced challenges with searching Spotify’s API efficiently, we’re proud of designing an application providing users with quickly-created and intuitively displayed song recommendations relating to their mood. We’re also excited by the capability to search multiple Spotify playlists to broaden options for song recommendations.

What we learned

Throughout the process of developing our program we all learned a lot. We learned how to utilize the Spotify API and also had to brush up our list comprehension skills as we utilized it to store the songs from the playlists that matched our mood. We also learned how to debug our code through different tests and just having each other look over the code. The final thing we learned was working as a group overall. We learned how to communicate each person’s idea with one another and to successfully take everyone’s input into consideration and end up with a final project we are proud of.

What's next for Moodify

Instead of representing mood as numbers, we hope to understand users' emotions (inputted as text) using machine learning. For example, if a user inputs “tired”, our app would recommend relaxing songs (lower energy, high valence) while if a user inputs “amazing,” our app would recommend upbeat songs (high energy, high valence).

We also plan to deeply integrate our app with the Spotify ecosystem, allowing users to play recommended tracks in the Spotify app with just a tap.

Further, we hope to use our active capability to search multiple Spotify playlists to provide more personalized track recommendations to users. Through deeply integrating with the Spotify ecosystem, we hope to obtain data regarding users’ artist and genre preferences, enabling us to provide customized mood-based song recommendations through searching playlists of specific artists/genres.

Installing and running

The user can pull the code directly from the GitHub repository to test the code on their local machine. The user will be prompted to describe their mood with a number on a scale from 1-10 and will then receive an output of song recommendations that best match that current mood.

Share this project:

Updates