Hi there, and welcome to this text! I’m going to elucidate how I built BeatBuddy, an internet app that analyzes what you’re listening to on Spotify. Inspired by Spotify Wrapped, it goals to interpret your current mood and supply recommendations you could tweak based on that evaluation.
Should you don’t need to read all the pieces and just want to present it a try, you’ll be able to achieve this here: BeatBuddy. For the remainder, keep reading!
The Birth of the Project
I’m an information analyst and a music lover, and I consider that data evaluation is a strong option to understand the world we live in and who we’re as individuals.
Music, specifically, can act as a mirror, reflecting your identity and emotions at a given moment. The style of music you select often is dependent upon your current activities and mood. For instance, if you happen to’re understanding, you may select an lively playlist to motivate you.
However, if you happen to are busy studying or specializing in crushing some data, chances are you’ll need to take heed to calm and peaceful music. I’ve even heard of individuals listening to white noise to focus, which might be described because the sound you hear while you open the windows of your automobile on the highway.
One other example of how music can reflect your mood is at a celebration. Imagine you’re having a celebration with friends and you’ve gotten to decide on the music. If it’s an informal dinner, it is advisable to play some smooth jazz or mellow tunes. But if you happen to’re aiming for the type of party where everyone finally ends up dancing on the furniture or doing their best drunken karaoke performance of an ’80s hit, you’ll need to select songs which might be energetic and danceable. We’ll come back to those concepts in a moment.
In actual fact, all of the music you take heed to and the alternatives you make can reveal fascinating points of your personality and emotional state at any given moment. Nowadays, people are inclined to enjoy analytics about themselves, and it’s becoming a worldwide trend! This trend is generally known as the “quantified self,” a movement where people use analytics to trace their activities, similar to fitness, sleep, and productivity, to make informed decisions (or not).
Don’t get me improper, as an information nerd, I really like all these items, but sometimes it goes too far — like with AI-connected toothbrushes. Firstly, I don’t need a toothbrush with a Wi-Fi antenna. Secondly, I don’t need a line chart showing the evolution of how well I’ve been brushing over the past six weeks.
Anyway, back to the music industry. Spotify was one in every of the pioneers in turning user data collection into something cool, and so they called it Spotify Wrapped.
At the tip of the yr, Spotify compiles what you’ve listened to and creates Spotify Wrapped, which fits viral on social media. Its popularity lies in its ability to disclose points of your personality and preferences you could compare to your pals.
This idea of how Spotify collects and aggregates data for these year-end summaries has all the time fascinated me. I remember asking myself, “How do they try this?” and that curiosity was the start line for this project.
Well, not exactly. Let’s be honest: The concept to investigate Spotify data was written on a note titled “data project”-you know, the type of note crammed with ideas you’ll probably never start or finish. It sat there for a yr.
In the future, I checked out the list again, and with a brand new confidence in my data evaluation skills (because of a yr of growth and enhancements of ChatGPT), I made a decision to select an item and begin the project.
At first, I just desired to access and analyze my Spotify data for no particular purpose. I used to be simply curious to see what I could do with it.
Starting a project like this, the primary query you need to ask yourself is where the information source is and what data is offered. Essentially, there are two ways to acquire your data:
- Within the privacy settings, you’ll be able to request a replica of your historical data, nevertheless it takes 30 days to be delivered — probably not convenient.
- Using Spotify’s API, which permits you to retrieve your individual data on demand and use different parameters to tweak the API call and retrieve various information.
Obviously, I went for the second option. To achieve this, you first must create a developer project to get your API keys, and then you definately’re good to go.
API Response Example
Remember we talked concerning the incontrovertible fact that certain tracks are more likely danceable than others. As human beings, it’s quite easy to feel if a song is danceable or not — it’s all about what you’re feeling in your body, right? But how do computers determine this?
Spotify uses its own algorithms to investigate every song in its catalog. For each song, they supply a listing of features related to it. One use of this evaluation is to create playlists and provide you with recommendations. The excellent news is that their API provides access to those analyses through the audio_features endpoint, allowing you to access all of the features of any song.
For instance, let’s analyze the audio features of the famous song “Macarena,” which I’m sure everyone knows. I won’t cover every parameter of the track intimately, but let’s deal with one aspect to higher understand how it really works — the danceability rating of 0.823.
In accordance with Spotify’s documentation, danceability describes how suitable a track is for dancing based on a mixture of musical elements, including tempo, rhythm stability, beat strength, and overall regularity. A rating of 0.0 is the least danceable, and 1.0 is probably the most danceable. With a rating of 0.823 (or 82.3%), it’s easy to say that this track could be very danceable.
The Three Temporalities
Before going further, I would like to introduce an idea with the Spotify API called time_range. This interesting parameter permits you to retrieve data from different time periods by specifying the time_range:
- short_term: the last 4 weeks of listening activity
- medium_term: the last 6 months of listening activity
- long_term: all the lifetime of your listening activity
Let’s illustrate this with an example: if you need to get your top 10 tracks from the last 4 weeks, you’ll be able to call the corresponding endpoint and pass the time_range as a parameter like this : https://api.spotify.com/v1/me/top/artists?time_range=short_term&limit=10
Calling this offers you your top 10 artists from the past month.
With all this information available, my idea was to create an information product that permits users to grasp what they’re listening to, and to detect variations of their mood by comparing different temporalities. This evaluation can then show how changes in our lives are reflected in our music decisions.
For instance, I recently began running again, and this alteration in my routine has affected my music preferences. I now take heed to music that is quicker and more energetic than what I typically listened to previously. That’s my interpretation, in fact, nevertheless it’s interesting to see how a change in my physical activity can affect what I take heed to.
This is only one example, as everyone’s musical journey is exclusive and might be interpreted otherwise based on personal experiences and life changes. By analyzing these patterns, I believe it’s pretty cool to give you the option to make connections between our lifestyle decisions and the music that we prefer to take heed to.
Making Data Insight Accessible
The deeper I got into this project, the more I got here to comprehend that, yes, I could analyze my data and are available to certain conclusions myself, but I wanted everyone to do it.
To me, the only option to share data insights with non-technical people and make it so very accessible shouldn’t be through a flowery BI dashboard. My idea was to create something universally accessible, which led me to develop a mobile-friendly web application that anyone could use.
To make use of the app, all you would like is a Spotify account, connect it to BeatBuddy with the clicking of 1 button, and also you’re done !
Measuring Musical Emotions
Let’s have a look at one other feature of the app: measuring the happiness level of the music you’re listening to, which could reflect your current mood. The app aggregates data out of your recent top tracks, specializing in the ‘valence’ parameter, which represents musical happiness, with 1 being super blissful music. As an example, if the typical valence of your current tracks is 0.432, and your all-time average is 0.645, it’d suggest a shift towards more melancholic music recently.
Nevertheless, these analyses ought to be taken with a grain of salt, as these numbers represent trends moderately than absolute truths. Sometimes, we shouldn’t all the time try to seek out a reason behind these numbers.
For instance, if you happen to were tracking your walking pace and discovered you’ve gotten been walking faster recently, it doesn’t necessarily mean you’re in additional of a rush — it might be as a result of various minor aspects like changes in weather, latest shoes, or just a subconscious shift. Sometimes changes occur without explicit reasons, and while it is feasible to measure these variations, they don’t all the time require straightforward explanations.
That being said, noticing significant changes in your music listening habits might be interesting. It might probably show you how to take into consideration how your emotional state or life situation is likely to be affecting your musical preferences. This aspect of BeatBuddy offers an interesting perspective, even though it’s price noting that these interpretations are just one piece of the complex puzzle of our emotions and experiences
Let’s be honest, analyzing your listening habits is one thing, but how do you’re taking motion based on this evaluation? In the long run, making data-driven decisions is the last word goal of knowledge evaluation. That is where recommendations come into play.
Recommendations Based on Your Chosen Mood
An interesting feature of BeatBuddy is its ability to supply music recommendations based on a mood you choose and the music you want.
As an example, you may realize that what you’re listening to has a rating of 75% popularity (which is kind of high), and you need to find hidden gems tailored to your tastes. You’ll be able to then tweak the “Popularity” slider to, say, 25% to create a fresh playlist with a mean rating of 25% popularity.
Behind the scenes, there’s an API call to Spotify’s algorithm to create a suggestion based on the factors you’ve chosen. This call generates a playlist suggestion tailored to each your preferences and the mood parameters you’ve set. It uses your top 5 recent tracks to fine-tune Spotify’s suggestion algorithm in response to your decisions.
When you’re blissful with the playlist, you’ll be able to reserve it on to your Spotify library. Each playlist comes with an outline that details the parameters you selected, helping you remember the mood each playlist is supposed to evoke.
Developing an internet application that analyzes Spotify data has been a difficult but rewarding journey. I actually have been pushed out of my comfort zone and gained knowledge in several areas, including web API, cookie management, web security, OAuth2, front-end development, mobile optimization, and search engine optimisation. Below is a diagram of the high-level architecture of the appliance:
My initial goal was to start out a modest data project to investigate my listening habits. Nevertheless, it become a three-month project wealthy in learning and discovery.
Throughout the method, I noticed how closely related data evaluation and web development are, especially on the subject of delivering an answer that shouldn’t be only functional but additionally user-friendly and simply accessible. In the long run, software development is actually about moving data from one place to a different.
One last note: I desired to create an application that was clean and provided a seamless user experience. That’s the reason BeatBuddy is totally ad-free, no data is sold or shared with any third parties. I’ve created this with the only real purpose of giving users a option to higher understand their music decisions and discover latest tracks.
You’ll be able to give the app a try here: https://www.beatbuddy.cloud
If you’ve gotten any comments or suggestions, I’m all ears! Your feedback is basically necessary.
For those focused on a deeper dive, keep a watch out for my upcoming article.
Cheers!
Lazare