How I Constructed BeatBuddy: A Internet App that Analyzes Your Spotify Information | by Lazare Kolebka | Aug, 2024


Picture generated by DALL·E 3

Hello there, and welcome to this text! I’m going to elucidate how I constructed BeatBuddy, an internet app that analyzes what you’re listening to on Spotify. Impressed by Spotify Wrapped, it goals to interpret your present temper and supply suggestions which you could tweak primarily based on that evaluation.

For those who don’t need to learn every little thing and simply need to give it a attempt, you are able to do so right here: BeatBuddy. For the remaining, maintain studying!

The Beginning of the Challenge

I’m an information analyst and a music lover, and I consider that information evaluation is a strong approach to perceive the world we reside in and who we’re as people.

Music, specifically, can act as a mirror, reflecting your identification and feelings at a given second. The kind of music you select usually relies on your present actions and temper. For instance, when you’re figuring out, you may select an brisk playlist to encourage you.

Alternatively, in case you are busy finding out or specializing in crushing some information, it’s possible you’ll need to hearken to calm and peaceable music. I’ve even heard of individuals listening to white noise to focus, which will be described because the sound you hear whenever you open the home windows of your automotive on the freeway.

One other instance of how music can mirror your temper is at a celebration. Think about you might be having a celebration with buddies and you must select the music. If it’s an off-the-cuff dinner, you may need to play some easy jazz or mellow tunes. However when you’re aiming for the form of get together the place everybody finally ends up dancing on the furnishings or doing their finest drunken karaoke efficiency of an ’80s hit, you’ll need to select songs which might be energetic and danceable. We’ll come again to those ideas in a second.

In reality, all of the music you hearken to and the alternatives you make can reveal fascinating features of your character and emotional state at any given second. These days, folks are inclined to get pleasure from analytics about themselves, and it’s changing into a worldwide development! This development is named the “quantified self,” a motion the place folks use analytics to trace their actions, equivalent to health, sleep, and productiveness, to make knowledgeable selections (or not).

Don’t get me mistaken, as an information nerd, I like all these items, however typically it goes too far — like with AI-connected toothbrushes. Firstly, I don’t want a toothbrush with a Wi-Fi antenna. Secondly, I don’t want a line chart displaying the evolution of how properly I’ve been brushing over the past six weeks.

Anyway, again to the music business. Spotify was one of many pioneers in turning person information assortment into one thing cool, they usually known as it Spotify Wrapped.

FIGURE I : Instance of Spotify Wrapped | Picture by the writer

On the finish of the 12 months, Spotify compiles what you’ve listened to and creates Spotify Wrapped, which fits viral on social media. Its recognition lies in its potential to disclose features of your character and preferences which you could examine to your pals.

This idea of how Spotify collects and aggregates information for these year-end summaries has at all times fascinated me. I bear in mind asking myself, “How do they do this?” and that curiosity was the start line for this mission.

Nicely, not precisely. Let’s be trustworthy: The thought to investigate Spotify information was written on a word titled “information mission”-you know, the form of word full of concepts you’ll in all probability by no means begin or end. It sat there for a 12 months.

Someday, I regarded on the checklist once more, and with a brand new confidence in my information evaluation abilities (because of a 12 months of progress and enhancements of ChatGPT), I made a decision to choose an merchandise and begin the mission.

At first, I simply wished to entry and analyze my Spotify information for no explicit function. I used to be merely curious to see what I might do with it.

Beginning a mission like this, the primary query you need to ask your self is the place the info supply is and what information is out there. Basically, there are two methods to acquire your information:

  1. Within the privateness settings, you may request a duplicate of your historic information, nevertheless it takes 30 days to be delivered — probably not handy.
  2. Utilizing Spotify’s API, which lets you retrieve your individual information on demand and use totally different parameters to tweak the API name and retrieve numerous info.

Clearly, I went for the second choice. To take action, you first have to create a developer mission to get your API keys, and you then’re good to go.

API Response Instance

Bear in mind we talked about the truth that sure tracks are extra possible danceable than others. As human beings, it’s fairly straightforward to really feel if a track is danceable or not — it’s all about what you’re feeling in your physique, proper? However how do computer systems decide this?

Spotify makes use of its personal algorithms to investigate each track in its catalog. For each track, they supply an inventory of options related to it. One use of this evaluation is to create playlists and provide you with suggestions. The excellent news is that their API offers entry to those analyses by the audio_features endpoint, permitting you to entry all of the options of any track.

For instance, let’s analyze the audio options of the well-known track “Macarena,” which I’m positive everybody is aware of. I gained’t cowl each parameter of the observe intimately, however let’s concentrate on one side to higher perceive the way it works — the danceability rating of 0.823.

FIGURE II : Instance of Macarena’s audio_features | Picture by the writer

Based on Spotify’s documentation, danceability describes how appropriate a observe is for dancing primarily based on a mixture of musical components, together with tempo, rhythm stability, beat power, and general regularity. A rating of 0.0 is the least danceable, and 1.0 is essentially the most danceable. With a rating of 0.823 (or 82.3%), it’s straightforward to say that this observe may be very danceable.

The Three Temporalities

Earlier than going additional, I have to introduce an idea with the Spotify API known as time_range. This attention-grabbing parameter means that you can retrieve information from totally different time durations by specifying the time_range:

  • short_term: the final 4 weeks of listening exercise
  • medium_term: the final 6 months of listening exercise
  • long_term: all the lifetime of your listening exercise

Let’s illustrate this with an instance: if you wish to get your high 10 tracks from the final 4 weeks, you may name the corresponding endpoint and move the time_range as a parameter like this : https://api.spotify.com/v1/me/top/artists?time_range=short_term&limit=10

Calling this gives you your high 10 artists from the previous month.

With all this info accessible, my thought was to create an information product that enables customers to know what they’re listening to, and to detect variations of their temper by evaluating totally different temporalities. This evaluation can then present how modifications in our lives are mirrored in our music decisions.

For instance, I lately began operating once more, and this alteration in my routine has affected my music preferences. I now hearken to music that’s sooner and extra energetic than what I sometimes listened to up to now. That’s my interpretation, in fact, nevertheless it’s attention-grabbing to see how a change in my bodily exercise can have an effect on what I hearken to.

This is only one instance, as everybody’s musical journey is exclusive and will be interpreted otherwise primarily based on private experiences and life modifications. By analyzing these patterns, I feel it’s fairly cool to have the ability to make connections between our life-style decisions and the music that we prefer to hearken to.

Making Information Perception Accessible

The deeper I received into this mission, the extra I got here to comprehend that, sure, I might analyze my information and are available to sure conclusions myself, however I wished everybody to do it.

To me, the only approach to share information insights with non-technical folks and make it so very accessible will not be by a elaborate BI dashboard. My thought was to create one thing universally accessible, which led me to develop a mobile-friendly internet utility that anybody might use.

To make use of the app, all you want is a Spotify account, join it to BeatBuddy with the clicking of 1 button, and also you’re executed !

FIGURE III : Instance of the appliance screens | Picture by the writer

Measuring Musical Feelings

Let’s take a look at one other characteristic of the app: measuring the happiness stage of the music you’re listening to, which might mirror your present temper. The app aggregates information out of your current high tracks, specializing in the ‘valence’ parameter, which represents musical happiness, with 1 being tremendous completely satisfied music. As an illustration, if the typical valence of your present tracks is 0.432, and your all-time common is 0.645, it’d recommend a shift in direction of extra melancholic music lately.

Nevertheless, these analyses ought to be taken with a grain of salt, as these numbers signify tendencies fairly than absolute truths. Typically, we shouldn’t at all times attempt to discover a purpose behind these numbers.

For instance, when you have been monitoring your strolling tempo and found you have got been strolling sooner these days, it doesn’t essentially imply you’re in additional of a rush — it could possibly be as a result of numerous minor components like modifications in climate, new sneakers, or just a unconscious shift. Typically modifications happen with out specific causes, and whereas it’s doable to measure these variations, they don’t at all times require easy explanations.

That being stated, noticing vital modifications in your music listening habits will be attention-grabbing. It might probably assist you concentrate on how your emotional state or life state of affairs may be affecting your musical preferences. This side of BeatBuddy presents an attention-grabbing perspective, though it’s value noting that these interpretations are just one piece of the complicated puzzle of our feelings and experiences

Let’s be trustworthy, analyzing your listening habits is one factor, however how do you’re taking motion primarily based on this evaluation? Ultimately, making data-driven selections is the last word objective of information evaluation. That is the place suggestions come into play.

Suggestions Based mostly on Your Chosen Temper

An attention-grabbing characteristic of BeatBuddy is its potential to supply music suggestions primarily based on a temper you choose and the music you want.

As an illustration, you may understand that what you might be listening to has a rating of 75% recognition (which is kind of excessive), and also you need to discover hidden gems tailor-made to your tastes. You may then tweak the “Recognition” slider to, say, 25% to create a contemporary playlist with a median rating of 25% recognition.

FIGURE IV : Adjustment of the recognition slider to 25% | Picture by the writer

Behind the scenes, there’s an API name to Spotify’s algorithm to create a advice primarily based on the factors you’ve chosen. This name generates a playlist advice tailor-made to each your preferences and the temper parameters you’ve set. It makes use of your high 5 current tracks to fine-tune Spotify’s advice algorithm in line with your decisions.

FIGURE V: API endpoint rationalization | Picture by the writer

When you’re proud of the playlist, it can save you it on to your Spotify library. Every playlist comes with an outline that particulars the parameters you selected, serving to you bear in mind the temper every playlist is supposed to evoke.

FIGURE VI: Saving a playlist to Spotify | Picture by the writer

Growing an internet utility that analyzes Spotify information has been a difficult however rewarding journey. I’ve been pushed out of my consolation zone and gained data in a number of areas, together with internet API, cookie administration, internet safety, OAuth2, front-end growth, cellular optimization, and web optimization. Under is a diagram of the high-level structure of the appliance:

FIGURE VII: Excessive stage structure | Picture by the writer

My preliminary objective was to start out a modest information mission to investigate my listening habits. Nevertheless, it was a three-month mission wealthy in studying and discovery.

All through the method, I noticed how intently associated information evaluation and internet growth are, particularly in relation to delivering an answer that isn’t solely practical but additionally user-friendly and simply accessible. Ultimately, software program growth is basically about shifting information from one place to a different.

One final word: I wished to create an utility that was clear and supplied a seamless person expertise. That’s the reason BeatBuddy is totally ad-free, no information is bought or shared with any third events. I’ve created this with the only real function of giving customers a approach to higher perceive their music decisions and uncover new tracks.

You can provide the app a attempt right here: https://www.beatbuddy.cloud

When you’ve got any feedback or solutions, I’m all ears! Your suggestions is actually essential.

For these excited about a deeper dive, maintain a watch out for my upcoming article.

Cheers!

Lazare

Leave a Reply

Your email address will not be published. Required fields are marked *