During this isolating and traumatic time of the COVID-19 pandemic, many people - including our team members and our friends - often turn to music as a coping mechanism. Although it has been reported that listening to sad music makes you feel better, recent research describes how listening to sad music also “increases depressive symptoms”. Listeners are unable to consciously pull themselves out of their listening pattern which results in a “higher level of negative mood responses”. To combat this, Moodify was born.

We were especially inspired to do this project because on Spotify we can see what our friends are listening to. If they are listening to something sad, we’d often want to help them in some way but don’t know how to approach them or the situation.

[Research Article Linked Here:]

What it does

Moodify is a web application that a user runs when they are listening to Spotify on their desktop. It takes what the user is listening to and if it finds that the song is sad then it intervenes by suggesting a more soothing/uplifting song so that they may feel better.

How we built it

We split into 2 groups for front-end and back-end. For the front-end, we used HTML, CSS, Javascript. This was then transferred over to Flask so that it could be integrated with our Python backend.

Our code for the algorithm works by using the Spotify API and a python library called Spotipy which helps us interact with the data from Spotify. This code works by first authenticating the Spotify user, then getting what they are listening to. This song has characteristic attributes called valence, danceability, and energy, each on a scale of 0.0 to 1.0. The lower each of these values are, the sadder it is. Through trial and error, certain values for each attribute were chosen so that any song with all 3 attributes under their respective value would be deemed to be a sad song. If the song is sad, the code suggests a random song from a playlist of 500+ songs with “Upbeat Positive Vibes”.

Challenges we ran into

Before our team started brainstorming ideas for this project, we knew we wanted to incorporate some kind of notification or chat-box feature on Spotify that responds to the type of music the user’s friends are listening to. This original idea became increasingly difficult to implement because of a few roadblocks.

Spotify’s web API developer doesn’t provide a way to retrieve friends’ activity data from Spotify which we needed for our original idea.

We used different languages for frontend and backend development (HTML, CSS, and JavaScript for front-end, Python for back-end). This became a problem later on when we wanted to combine both ends.

Also, none of us really had prior experience with most of the coding languages and technologies we ended up using so there was a big learning curve.

Accomplishments that we're proud of

We’re all beginner hackers so completing this project in the span of two days, with little to no background knowledge was surprising. Also, implementing a basic machine learning algorithm through our code definitely seemed out of our league but using a lot of digging, learning on the internet, and getting advice from mentors helped a ton!

What we learned

We learned how to code in HTML, Javascript, and used CSS to create and style the web app. Also, we learned about Spotify’s API, the Spotipy library, and a micro web framework called Flask that uses Python. We also learned how to use JSON!

What's next for Moodify

In the future, we would like to make this a functional web application with developed UX/UI, and also expand this across other music platforms and not just for Spotify. Additionally, we hope to make this into a mobile app as well. We would also like to consider looking into adding a CBT (Cognitive Behavioural Therapy) Bot and a chat box so that the bot may talk to the user if the user wishes to talk to the bot.

Share this project: