Skip to main content

No project description provided

Project description

Stain

Fast audio fingerprinting for Python

Install

pip install music-stain

Usage

fp = music_stain.PyFingerprinter()
hashes = fp.fingerprint_file("song.wav")

for h in hashes:
    print(f"{h.hash} @ {h.time}")

API

PyFingerprinter() - Create fingerprinter
.fingerprint_file(path) -> list[PyHash] - Returns fingerprint hashes

PyHash
.hash: int - Fingerprint hash value
.time: int - Time offset (frames)

Matching Example

Build database:

db = {}
for h in fp.fingerprint_file("song.wav"):
    db.setdefault(h.hash, []).append(("song_id", h.time))

Match query:

matches = {}
for h in fp.fingerprint_file("query.wav"):
    if h.hash in db:
        for song_id, db_time in db[h.hash]:
            offset = db_time - h.time
            matches[(song_id, offset)] = matches.get((song_id, offset), 0) + 1

best = max(matches.items(), key=lambda x: x[1])
print(f"Matched: {best[0][0]} with {best[1]} hits")

Formats

WAV, MP3, FLAC, OGG, M4A, etc.

License

MIT

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

If you're not sure about the file name format, learn more about wheel file names.

music_stain-0.1.5-cp310-cp310-manylinux_2_34_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

music_stain-0.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

File details

Details for the file music_stain-0.1.5-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for music_stain-0.1.5-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 02d3c94a3e3e303b3a6a4a2abaeac3958e6a055ae0cee0cf61b26a12808a78cc
MD5 e91305d965f453700ffbc6de13d9a373
BLAKE2b-256 94af6c3d73b62f5cbc5900ca2bd8442667e0f929b2d0fbd70a26d64a795a28ad

See more details on using hashes here.

File details

Details for the file music_stain-0.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for music_stain-0.1.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a8e50277efff59fe072185e246c5f74b97f75d25b20da2bc7a1fb179d83df97b
MD5 b720c14f8361baa451bac7957c64d12f
BLAKE2b-256 24e88930230e6c9338eeaba8e5a9e494769b4d71f7f830a9685acfa439ff38cd

See more details on using hashes here.

Supported by

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