Skip to main content

Shazam API wrapper

Project description

shazam.py

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.

Install

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.

Usage

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

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)

There is also support for using your own session objects and using Shazam and AsyncShazam outside of a context manager using the execute function.

Notes on the Shazam API

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.

Why is this better than all other libraries ever?

Because rust

Credits to:

https://github.com/marin-m/SongRec https://github.com/Numenorean/ShazamAPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

shazam.py-1.0.0-cp310-none-win_amd64.whl (361.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

shazam.py-1.0.0-1-cp310-none-win_amd64.whl (361.0 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page