How Spotify’s algorithms listen to music
Computers listen to music, and with Spotify’s API we might learn what they hear.
If you are not a subscriber of The Fanbase Builder, join the dozens of artists, creators and music industry executives who receive it for free.
Let’s dive into today’s topic:
How Spotify’s algorithms listen to music
Computers listen to music, and with Spotify’s API, we might learn what they hear.
Why it matters
With the rise of AI, machines may become the most important influencers in music discovery. Therefore, it's important to have a basic understanding of how these machines consume music.
How it works
The Spotify Developer Console provides a lot of behind-the-scenes information about music. Two so-called endpoints give a glimpse into how Spotify’s machines listen to music:
/audio-features shows how Spotify indexes music based on mood-specific variables like acousticness and danceability. The web API's documentation on audio features provides extensive detail on these variables. For example:
valence number A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track. Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while tracks with low valence sound more negative (e.g. sad, depressed, angry).
/audio-analysis shows how the AI translates audio into data. A song is divided into thousands of tiny pieces of a few milliseconds each. These pieces are analysed and measured to variables like loudness, tempo, key, confidence, and timbre. The web API’s documentation on audio analysis provides a lot of information about this process. For example:
mode Indicates the modality (major or minor) of a section, the type of scale from which its melodic content is derived. This field will contain a 0 for "minor", a 1 for "major", or a -1 for no result. Note that the major key (e.g. C major) could more likely be confused with the minor key at 3 semitones lower (e.g. A minor) as both keys carry the same pitches.
Now we know how Spotify’s machines translate music into zeros and ones, it is easier to understand how some of the most popular playlists are composed by algorithms - such as Discover Weekly and Daily Mix.
Yes, but..
How machines listen to music is only a small part of the story. Ultimately, a song’s success is determined by human emotions and actions rather than algorithms. Humans listen to music and decide whether they like it or not. Algorithms only suggest what they are trained to recommend based on the machine learning of listening behaviour.
Take action now
A few years ago, I co-wrote an exercise to help people learn the Spotify Developer Console for the Artist Lockdown Challenge. It's geeky stuff, but don't let that hold you back. It's easier than you think. Check it out:
Further reading
Understanding the Spotify Web API (Spotify R&D Engineering, from 2015!)
How “Fans Also Like” Works (Spotify for Artists)