foley.index.taxonomy.resolver#
Resolve free tags/caption/labels to a UCS CatID (the EnvSound-UCS pipeline).
Staged precedence, highest wins (report 04 §5.3, [11 §3.1] — normalize heterogeneous labels onto UCS via mapping/synonym tables):
filename-parse > keyword/synonym > audioset-map > none
Matching is word-boundary aware (so "rain" matches “heavy rain” but not
“brainstorm”), a subcategory hit outranks a category-name hit, and multi-word
phrases outrank single tokens — with a deterministic table-order final tiebreak.
The always-available default is this stdlib KeywordResolver; a richer
CLAP zero-shot resolver (embed once, argmax over UCS label prompts, report
03 Part 2) can be dropped in behind the same TaxonomyResolver protocol.
Functions
|
Resolve inputs to a best UCS CatID by the staged precedence. |
Classes
|
The default stdlib resolver — staged keyword/synonym/AudioSet resolution. |
|
Resolve a |
- class foley.index.taxonomy.resolver.KeywordResolver(*, table=None, audioset_map=None)[source]#
Bases:
objectThe default stdlib resolver — staged keyword/synonym/AudioSet resolution.
Zero heavy dependencies. Bind a different
TaxonomyResolver(e.g. a future CLAP zero-shot resolver) by keyword injection to upgrade quality.- resolve(record)[source]#
Resolve a
SoundRecord’s tags/caption/labels/uri.- Return type:
- class foley.index.taxonomy.resolver.TaxonomyResolver(*args, **kwargs)[source]#
Bases:
ProtocolResolve a
SoundRecordto a UCS CatID.
- foley.index.taxonomy.resolver.resolve_catid(*, tags=(), caption=None, audioset_labels=(), filename=None, table=None, audioset_map=None)[source]#
Resolve inputs to a best UCS CatID by the staged precedence.
- Parameters:
audioset_labels (
Sequence[str]) – AudioSet MIDs or names (e.g. from PANNs).filename (
Optional[str]) – Optional UCS-style filename/path (its token-0 CatID wins if recognized).table (
Optional[UcsTable]) – UCS table (defaults todefault_ucs_table()).audioset_map (
Optional[AudioSetUcsMap]) – AudioSet->UCS map (defaults todefault_audioset_ucs_map()).
- Return type:
- Returns:
A
CatIdResolution(falsy when nothing resolved).