Skip to main content

Music Identification Through Audio Fingerprinting

PyPI PyPI - Python Version PyPI - License
Identifies a song from a small recording (say 30 seconds). The song has to be a part of your created database, of course.

This project is essentially a simplified version of what Shazam does.

The Idea

The flowchart on the right describes the series of steps.

Below is a brief summary. For detailed explanation with analysis, check out our Report.

We decimate the audio signal by a factor of 4 after passing it through a low pass filter (to smartly avoid aliasing). Thereafter, the signal is converted to frequency domain using the famous Fast Fourier Transform.

We take small chunks of the sample (roughly 0.3 seconds) and take the peak frequencies along a logarithmic scale. Those values are then associated with a hash value. We do so for all the songs and hence create a database.

We perform similar steps for the recorded sample. The answer is the song with the highest number of matches for a particular offset value.

Requirements

  • Python 3+.
  • pip (package installer for Python). See here for installation.
  • ffmpeg. See here for installation.
  • PortAudio. Only for Linux/OSX users. Check your distribution's repos for latest builds. Instead you can also build it from source, see here.

Installation

  • Install using pip (preferred in a virtual environment).
pip install Presto-Chango

Usage

  • On the first run, create your database by specifying the location of your songs directory.
presto-chango create-db <songs-directory>
  • Identify a song by either recording in real time or using a pre-recorded sample.
# Record in real time
presto-chango identify

# Use a pre-recorded sample
presto-chango identify --file=samples/sample1.wav
  • The algorithm returns the top five matches and the number of offsets that matched for each of them. Example
$ presto-chango identify --file="samples/sample_GAY.wav"
  Loading database
  .
  .
  .
  Database loaded

  Processing...

  Results:
  Kane Brown - Good as You (Official Music Video)_mS3TeZEp_PE.wav 41
  Katy Perry - Never Really Over (Official)_aEb5gNsmGJ8.wav 39
  Ed Sheeran - Perfect (Official Music Video)_2Vv-BfVoq4g.wav 37
  Cody Johnson - On My Way To You (Official Music Video)_RKUENGsDXBA.wav 24
  Jason Aldean - Rearview Town_WEUUvntknTI.wav 23

Building the source code

  • Clone the repository
git clone https://github.com/yashrajkakkad/presto-chango.git
cd presto-chango
  • Create a virtual environment
python -m venv venv
source venv/bin/activate
  • Install the package. The --editable flag makes it so that we don't have to reinstall everytime we make some change.
pip install --editable .

Testing

You can run the tester code if you're too lazy to record songs. It will cut random 30 second samples from songs and run the algorithm.

python tester.py

References

Metadata

Release files for Presto-Chango 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Presto-Chango 1.0.2
File Size Uploaded
Presto Chango-1.0.2.tar.gz 9.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Presto-Chango 1.0.2
File Interpreter ABI Platform
Presto_Chango-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / Presto Chango-1.0.2.tar.gz

Download URL Presto Chango-1.0.2.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c140138bc54fffe88ffba2d217bd661b85969f111b28fc17ed819a499216ed42
BLAKE2b-256 checksum
How to use checksums
2d6bdfe3d7bf8af627a0dfacc00fea0fc1083ce50c3ba164c66626acecad261b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1

Release files / Presto_Chango-1.0.2-py3-none-any.whl

Download URL Presto_Chango-1.0.2-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68660c7d95d9f527c5c235a7bd2bd76eab45848bff39f2f6ff319e956719e825
BLAKE2b-256 checksum
How to use checksums
47f5ec2b90fccabd0cebcb9ba94ed9d6ffc359ef1ff0f686ad17af83a00e28b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.1

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page