Python library for the Shazam API. This library is based off of ShazamAPI and SongRec but some added features.
NOTE: that this is still in its design and development phase. It works and *could* be used in production but beware of possible breaking changes.
pip3 install shazam.py
If you're on linux, you'll also have to install pkg-config
and libasound2-dev
with your preferred package manager.
Synchronous Shazam:
from shazam import Shazam
mp3_file = open('a.mp3', 'rb').read()
with Shazam(mp3_file) as shazam:
print(shazam.result) # data received from the shazam api
print(shazam.response.name) # structured data
A partially-asynchronous method is also provided: (partially because only requests are done asynchronously and not the signature generation. See #1)
from shazam import AsyncShazam
mp3_file = open('a.mp3', 'rb').read()
async with AsyncShazam(mp3_file) as shazam:
print(shazam.result)
print(shazam.response.name)
There is also support for using your own session objects and using Shazam
and AsyncShazam
outside of
a context manager using the execute function.
Shazam's api takes a "signature" of a song to search in their database before returning a result.
If you want to know more about the specifics of the algorithm, you can read the paper written by a co-founder of Shazam.
The implementation of the algorithm was written by @marin-m in their project. It was adapted to work with python through pyo3 here.