foley.index.taggers#
Taggers — auto-fill a sound’s semantic labels on ingest (report 03).
Two default taggers behind the Tagger protocol:
ClapZeroShotTagger— foley’s default. Scores a clip against a custom/UCS label set by CLAP cosine (report 03 Part 2), **reusing the same embedder the Index already loads** — so ingest never loads CLAP twice and it needs no dependency beyondfoley[clap].
PannsTagger— PANNs CNN14 supervised tagging over the 527 AudioSet classes (report 03 Part 1);foley[tag]. The checkpoint auto-downloads (~327 MB) on first use.
Captioners (EnCLAP / Qwen2-Audio, foley[caption]) plug in behind the
Captioner protocol as adapters; none ships as a
default yet (no clean, permissively-licensed, pip-installable checkpoint), so the
ingest caption stage is off unless a captioner is injected.
Heavy deps (torch/transformers/panns_inference) are lazy-imported, so
importing this module costs only the stdlib.
Module Attributes
Prompt template for zero-shot CLAP tagging (report 03 Part 2). |
|
PANNs CNN14 expects 32 kHz mono audio. |
|
Where panns-inference keeps (and, when missing, |
|
panns-inference treats a smaller checkpoint as incomplete and fetches it again. |
Functions
The default supervised tagger (PANNs CNN14; |
|
|
The default zero-shot tagger (CLAP vs UCS subcategories; |
Classes
|
Zero-shot tagger: score a clip against a label set via CLAP cosine. |
|
PANNs CNN14 supervised tagger over the 527 AudioSet classes ( |
- class foley.index.taggers.ClapZeroShotTagger(*, embedder=None, labels=None, prompt='this is a sound of {label}', threshold=0.0)[source]#
Bases:
objectZero-shot tagger: score a clip against a label set via CLAP cosine.
Reuses a
ClapEmbedder(the same model the Index uses), so the audio is embedded in the same joint space as the label prompts and no extra weights load. The default label set is the UCS subcategory names (foley’s own vocabulary), so tags land in-taxonomy.- property embedder#
The CLAP embedder (injected or the process-wide default).
- property labels: list[str]#
natural UCS
category subcategoryphrases).Natural multi-word phrases (
"weather rain","glass break") are far better CLAP prompts — and better BM25 tags / taxonomy-resolver input — than bare abstract subcategory words ("Break","Buzz"), which are a known zero-shot artifact (anomalously close to everything). Absolute tag-quality calibration (thresholds, label curation) is an eval-harness concern (#10).- Type:
The label vocabulary (default
- tag(wav, sr, *, taxonomy='custom', top_k=10)[source]#
Return the top-
k(label, cosine)tags for the clip, best first.
- foley.index.taggers.PANNS_CHECKPOINT_MIN_BYTES = 300000000#
panns-inference treats a smaller checkpoint as incomplete and fetches it again.
- foley.index.taggers.PANNS_DATA_DIR = '~/panns_data'#
Where panns-inference keeps (and, when missing,
wget-downloads) its files.
- class foley.index.taggers.PannsTagger(*, device='cpu', threshold=0.1)[source]#
Bases:
objectPANNs CNN14 supervised tagger over the 527 AudioSet classes (
foley[tag]).The checkpoint auto-downloads to
~/panns_data(~327 MB) on the firsttag(). PANNs expects 32 kHz mono; the clip is resampled viafoley.audio.to_working().
- foley.index.taggers.ZEROSHOT_PROMPT: str = 'this is a sound of {label}'#
Prompt template for zero-shot CLAP tagging (report 03 Part 2).
- foley.index.taggers.default_tagger()[source]#
The default supervised tagger (PANNs CNN14;
foley[tag]).- Return type:
- foley.index.taggers.default_zeroshot_tagger(embedder=None)[source]#
The default zero-shot tagger (CLAP vs UCS subcategories;
foley[clap]).Cached per embedder so the tagger is bound to the SAME embedder that produced the audio vector it scores — otherwise (report seam) the cosine would cross two unrelated embedding spaces.
embedder=Noneuses the process-wide default embedder.- Return type: