Thursday, 19 December 2019

Shazam


In this first tech blog we will talk how Shazam app works. Some of you might even don't know what Shazam app is. Imagine you are in the classroom and your teacher has not yet arrived. Suddenly someone starts playing a song and after listening the song for a few seconds you start liking that song but you don't know the name of the song. This is where Shazam comes into play. Shazam records the song for a few seconds and tells the name of the song along with the name of artist and album. Now in coding we know that this can be done by comparing all the songs in Shazam's database with the recorded song. But it will take a lot of computation time as there are millions of songs in it. So how does Shazam recognises a song within a few seconds?


At first, we need to understand how Shazastores songs in its database. Firstly it converts the song into its spectrogram. Spectrogram is a 3-D graph of song with time on the x-axis, frequency on the y-axis and amplitude on the z-axis which is representated by a colour. It looks something like this,





It is then converted to its audio fingerprint which is a 2-D star map extracted from its spectrogram where each star or peak represents the strongest frequency at a particular time. It looks something like this,




After this they create a combinatorial hash for each peak. Hashing function in computer science is a function which takes a varying length of input and produces a fixed length output (in this case 32-bit integer) which is known as hash. Combinatorial hashing involves selecting a peak as an anchor point and a target zone of multiple neighbouring peaks. The anchor pint is paired with each peak in the target zone which produces a time frequency vector. All of these vectors are then inputted in a hash function which creates a unique hash for each song. Each hash is linked to the song name, artist and album.When you open Shazam app and record a song, it instantly creates its audio fingerprint filtering the noise because it only produces data points for stand out frequencies. After this as the process explained above, it creates its unique hash and finds a match very easily.

No comments:

Post a Comment