clapback-client
The contract a tool follows to take part in the clapback commons — look up before you contribute, send what the records require, back off when told to — with no dependency beyond the standard library.
pip install clapback-client
from clapback_client import Corpus, fingerprint_file, hash_fingerprint
key = hash_fingerprint(fingerprint_file("track.flac"))
corpus = Corpus()
row = corpus.lookup(key, pipeline_version)
if row is not None:
vector = row["embedding"] # the commons already had it — skip the model
else:
vector = my_embedder(path) # your pipeline, declared by `pipeline_version`
corpus.contribute(
fingerprint_hash=key,
embedding=vector,
pipeline_version=pipeline_version,
client_id=client_id,
)
What a tool has to do
Four things. Each is decided in one of the project's records, and this package is those decisions as code so a tool does not have to reimplement them.
- Fingerprint the audio and hash it canonically.
hash_fingerprintis SHA256 of the AcoustID fingerprint exactly as chromaprint returns it — not as your database happened to store it. That distinction split a corpus once;canonical()is the guard. - Produce the vector through a declared pipeline. This package never embeds. The reference
pipeline is
clapback-embed, whosePIPELINE_VERSIONis the identity to send. A tool with its own pipeline declares its own identity, and its vectors are comparable with each other rather than with the reference's. - Look up before contributing.
Corpus.hasorCorpus.lookup. A repeat submission is recorded as agreement, so a tool that re-sent its library would manufacture evidence of one install agreeing with itself — the one measurement the commons exists to make honestly. - Send
client_idandpipeline_version. Both are required byCorpus.contributeand have no defaults.client_idis a random UUID minted once per install —identity.mint_client_id— on the first contribution, never on install, and stored where the user can find and delete it.
What you get back
- Skip the recompute.
lookupreturns the stored vector for a recording the commons already holds under your pipeline. - Similarity across libraries you do not own.
similar(vector)returns the nearest recordings the commons holds, each with arecording_mbidwhen anyone has claimed one — a MusicBrainz recording a person can look up — and a bare hash when nobody has.recording(mbid)goes the other way: what does recording X sound like, without holding X. - Confirmation — whether your vector for a recording agrees with others' independently computed one.
Naming what you contribute
If your tool knows the MusicBrainz recording id — beets' mb_trackid, Picard's recording id,
an AcoustID lookup's result — pass it as recording_mbid= on contribute, or attach it later with
claim() to a row you already sent. Never re-send the vector to add an id: a repeat contribution
is recorded as agreement, and your library must not read as agreeing with itself.
An id is a claim: the commons counts how many distinct clients assert it and never verifies it against MusicBrainz. Sending one tells the operator which recording you hold — so send it under the same setting that sends the vector, and say so in your own "what leaves the machine".
The commons is worth exactly its coverage of the library asking. Early on, expect misses.
Fingerprinting needs chromaprint, and only fingerprinting does
brew install chromaprint # or: apt install libchromaprint-tools
pip install pyacoustid
fingerprint_file runs it out of process, because chromaprint is a C library that crashes rather
than raises on some malformed inputs and one bad file must not end a run. If your tool already has
fingerprints — beets' chroma plugin stores them, Picard computes them natively — hand them to
hash_fingerprint directly and skip this.
Opt-in, off by default
Nothing in this package sends anything until you call contribute or claim. A tool that embeds
this should keep contribution a separate, explicit setting from lookup, and should tell the user
what leaves the machine — a 512-float vector, a one-way hash, and a MusicBrainz recording id if
you pass one; never audio, filenames, or other tags — before the first time it does.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clapback_client-0.2.0.tar.gz.
File metadata
- Download URL: clapback_client-0.2.0.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc882962fad39f535ec4ff582aa0985ae37d7075328337ad40bd2308dc835e6b
|
|
| MD5 |
06738c9983d4d890b3009be6d2fa71cd
|
|
| BLAKE2b-256 |
2420b92109b16b26eca5a5db6df18a11e2313d26a06e24410685f97957e066f4
|
Provenance
The following attestation bundles were made for clapback_client-0.2.0.tar.gz:
Publisher:
client-release.yml on seethroughlab/clapback
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clapback_client-0.2.0.tar.gz -
Subject digest:
fc882962fad39f535ec4ff582aa0985ae37d7075328337ad40bd2308dc835e6b - Sigstore transparency entry: 2821829609
- Sigstore integration time:
-
Permalink:
seethroughlab/clapback@6915ca6542eeff92bd1c6ab98bb41d844a25d068 -
Branch / Tag:
refs/tags/client-v0.2.0 - Owner: https://github.com/seethroughlab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
client-release.yml@6915ca6542eeff92bd1c6ab98bb41d844a25d068 -
Trigger Event:
push
-
Statement type:
File details
Details for the file clapback_client-0.2.0-py3-none-any.whl.
File metadata
- Download URL: clapback_client-0.2.0-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0cca845526770baa794a9f8dfdf9bb8b57fa7e81f9d513f5596c977782fe920a
|
|
| MD5 |
6dfc51aa245aae89ab2d5c531e4cae04
|
|
| BLAKE2b-256 |
8d5572745b19fd286530d7582532c5728f2bddebd045eb78bdac17daeee93934
|
Provenance
The following attestation bundles were made for clapback_client-0.2.0-py3-none-any.whl:
Publisher:
client-release.yml on seethroughlab/clapback
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clapback_client-0.2.0-py3-none-any.whl -
Subject digest:
0cca845526770baa794a9f8dfdf9bb8b57fa7e81f9d513f5596c977782fe920a - Sigstore transparency entry: 2821829690
- Sigstore integration time:
-
Permalink:
seethroughlab/clapback@6915ca6542eeff92bd1c6ab98bb41d844a25d068 -
Branch / Tag:
refs/tags/client-v0.2.0 - Owner: https://github.com/seethroughlab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
client-release.yml@6915ca6542eeff92bd1c6ab98bb41d844a25d068 -
Trigger Event:
push
-
Statement type: