foley.base#
Canonical data models for foley — the single source of truth (SSOT) types.
This module is stdlib-only and declarative: it defines the dataclasses, enums,
and affordance registries every other layer shares, plus generic dict/JSON
(de)serialization. It contains NO policy (see foley.licensing) and NO I/O
(see foley.stores / foley.audio).
Serialization contract:
record.to_dict()-> a plain dict (nested dataclasses recursed viadataclasses.asdict; enum members preserved, and JSON-safe because every enum subclassesstr).
record.to_json()-> a JSON string.
Cls.from_dict(d)/Cls.from_json(s)-> reconstructs, coercing enum fields from their string values and nestedLicenseRecordfrom its dict. Unknown keys are ignored (forward-compatible schema evolution); missing keys fall back to field defaults.
Module Attributes
The match kinds whose sound may not sit on its cue word, and why — the SSOT the weave notes and the taste eval both flag (#263). |
|
Unified query-stage parameters (search / find / filter surface). |
|
Unified generation-stage parameters (generate backends map onto these). |
|
an edit is a generation whose input includes a source clip. |
|
each is offered by two or more providers). |
|
The |
|
The ISO 3166-1 alpha-2 country codes (the 249 officially assigned). |
|
the UK's common one and the EU's code for Greece. |
|
The territory of a sound used everywhere (online publishing reaches every country): a licence that excludes any territory refuses it (#175). |
|
The named delivery targets (report 06 §5.2). |
Functions
|
Raise |
|
|
|
|
|
Raise |
|
Resolve a master spec (profile name, explicit profile, or |
Classes
|
How a sound entered foley (retrieval channel or origin). |
|
Descriptor for a unified parameter affordance (arioso analog). |
|
How a WEAVE |
|
A ranked, license-checked, (optionally) verified sound for one SoundEvent. |
|
Whether a candidate was retrieved from the index or freshly generated. |
|
One edit operation and the |
|
What the caller intends to do with a sound; consumed by |
|
Mix layer (shared by |
|
Per-sound rights + provenance. |
|
Loudness master target — the delivery spec as data, not code (report 06 §5.2). |
|
HOW a |
|
WHERE/WHEN a clip sits — a symbolic anchor plus its resolved time (report 06 §6.3). |
|
HOW a clip sounds — all optional with identity defaults (report 06 §3, §6.3). |
|
How prominent a sound event is within a passage. |
Adds |
|
|
The editable, re-renderable sound-design plan — the SELECT→WEAVE bridge and render SSOT. |
|
One salient, physically-audible event decomposed from a passage. |
|
Canonical SSOT per sound. |
|
How a sound's bytes are held (DERIVED from |
|
One placed sound on the sound-design timeline — sparse seed + resolved render fields. |
|
The result of one verification rung for a candidate. |
|
Which rung of the verification ladder produced a |
- class foley.base.AcquisitionMethod(*values)[source]#
-
How a sound entered foley (retrieval channel or origin).
- class foley.base.Affordance(name, type, description, default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None)[source]#
Bases:
objectDescriptor for a unified parameter affordance (arioso analog).
- carries_meaning#
Dropping it would change what the caller gets (a seed they will rely on to reproduce, content they asked to exclude), so a backend that cannot honour it raises instead of dropping it (#53).
- Type:
- choices#
The values it accepts, when it is an enumeration (
sort,kind); any other value raisesValueErrorbefore any call.
- renamed_from#
The name it had before a release renamed it (#75): passing the old name raises a
TypeErrornaming this one (seereject_renamed()). For a generation affordance, the generations cache still reads entries kept under the old name.
- bounds#
(lo, hi)for a number (either endNone: open), checked before any call where the affordance’s registry says so (seecheck_edit_args()).
- class foley.base.Anchor(*values)[source]#
-
How a WEAVE
Placementbinds its symbolic time to the narration (report 06 §2.4).absoluteis a fixed offset; the rest resolve against the forced-alignedword_timeline—wordto a trigger word’s onset,sentenceacross a sentence span,scene/paragraphto a boundary’s first spoken word.
- class foley.base.Candidate(sound, origin=CandidateOrigin.retrieved, event=None, clap_score=None, bm25_score=None, rrf_score=None, rerank_score=None, verdict=None, license_ok=None, preview_uri=None, notes=list(), cost_estimate_usd=None, cost_actual_usd=None)[source]#
Bases:
SerializableMixinA ranked, license-checked, (optionally) verified sound for one SoundEvent.
Retrieval and generation return the SAME shape; only
origindiffers. Nestedsound/event/verdictdataclasses are decoded generically by_decode()— no per-field code needed.- audio_bytes = None#
The clip’s bytes when foley holds them nowhere it can serve them from — a
generate(store=False)preview (the archive bytes the library would have stored). A plain class attribute, NOT a dataclass field, so it is never serialized:to_dict/to_jsonstay byte-free (cf.IngestReport.exception).copy/deepcopy/picklekeep it;dataclasses.replaceand afrom_dictround trip drop it.
- raw = None#
the item JSON a retrieve source parsed it from (Freesound), or what a generator returned besides the audio (see
foley.sources.base.GeneratedClip.raw), elseNone. Likeaudio_bytes, a plain class attribute, NOT a dataclass field: it is never serialized, so it never reaches the meta store however large it is.- Type:
The provider’s own payload for this candidate (#61)
- class foley.base.CandidateOrigin(*values)[source]#
-
Whether a candidate was retrieved from the index or freshly generated.
- foley.base.EDIT_AFFORDANCES: dict[str, Affordance] = {'audio': Affordance(name='audio', type=<class 'object'>, description='The source clip to edit (a URL, a local path or bytes; keyed by content)', default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=None), 'extend_after_s': Affordance(name='extend_after_s', type=<class 'float'>, description='Seconds of new sound after the source', default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=(0.0, None)), 'extend_before_s': Affordance(name='extend_before_s', type=<class 'float'>, description='Seconds of new sound before the source', default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=(0.0, None)), 'inpaint_end_s': Affordance(name='inpaint_end_s', type=<class 'float'>, description='End of the window to regenerate (s into the source)', default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=(0.0, None)), 'inpaint_start_s': Affordance(name='inpaint_start_s', type=<class 'float'>, description='Start of the window to regenerate (s into the source)', default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=(0.0, None)), 'strength': Affordance(name='strength', type=<class 'float'>, description="0..1 how far from the source (1.0 is pure generation); None => the backend's", default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=(0.0, 1.0))}#
an edit is a generation whose input includes a source clip. Only a source whose config declares
modes=['edit']takes them (seefoley.edit()); a text-to-audio or video-to-audio source refusesaudio=.- Type:
Edit-stage parameters (#162)
- foley.base.EDIT_OPS: dict[str, EditOp] = {'audio_to_audio': EditOp(name='audio_to_audio', description='Regenerate the whole clip from the source (strength: how far from it)', requires=(), requires_any=(), accepts=('strength',), ordered=(), within_clip=(), adds=()), 'extend': EditOp(name='extend', description='Add new sound before and/or after the source', requires=(), requires_any=('extend_before_s', 'extend_after_s'), accepts=(), ordered=(), within_clip=(), adds=('extend_before_s', 'extend_after_s')), 'inpaint': EditOp(name='inpaint', description='Regenerate one window of the source, keeping the rest', requires=('inpaint_start_s', 'inpaint_end_s'), requires_any=(), accepts=(), ordered=(('inpaint_start_s', 'inpaint_end_s'),), within_clip=('inpaint_start_s', 'inpaint_end_s'), adds=())}#
each is offered by two or more providers).
- Type:
SSOT
- Type:
the edit operations (report 13 §3
- foley.base.EDIT_TRANSFORMATION = 'edit'#
The
kindof thetransformationsentry an edit appends to its clip’s licence (#162): what it derives from (seefoley.sources.edit.EditLineage).
- class foley.base.EditOp(name, description, requires=(), requires_any=(), accepts=(), ordered=(), within_clip=(), adds=())[source]#
Bases:
objectOne edit operation and the
EDIT_AFFORDANCESit takes (a row ofEDIT_OPS).- output_seconds(clip_s, params)[source]#
How long the op’s output is for a
clip_ssource (None: unknown), when noduration_ssets it: the source’s length plus whataddsadds.>>> EDIT_OPS["extend"].output_seconds(4.0, {"extend_after_s": 2.0}) 6.0 >>> EDIT_OPS["inpaint"].output_seconds(4.0, {"inpaint_start_s": 1.0}) 4.0
- foley.base.GENERATION_AFFORDANCES: dict[str, Affordance] = {'duration_s': Affordance(name='duration_s', type=<class 'float'>, description='Seconds; None => backend auto', default=None, stage='generate', carries_meaning=False, choices=None, renamed_from='duration', bounds=None), 'expand_prompt': Affordance(name='expand_prompt', type=<class 'bool'>, description='Let the backend rewrite the prompt (the prompt it used is recorded)', default=None, stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'keep_source_audio': Affordance(name='keep_source_audio', type=<class 'bool'>, description="Keep the video's own speech and build the sound around it", default=False, stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'loop': Affordance(name='loop', type=<class 'bool'>, description='Seamless-loopable clip', default=False, stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'model': Affordance(name='model', type=<class 'str'>, description="Pin a model / version (stored as generator_version); None => the backend's", default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=None), 'negative_prompt': Affordance(name='negative_prompt', type=<class 'str'>, description='Content to exclude', default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=None), 'output_format': Affordance(name='output_format', type=<class 'str'>, description='wav|opus|mp3', default='wav', stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'preset': Affordance(name='preset', type=<class 'str'>, description='Category preset (procedural sources)', default=None, stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'prompt': Affordance(name='prompt', type=<class 'str'>, description='Sound description', default=None, stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'prompt_influence': Affordance(name='prompt_influence', type=<class 'float'>, description="0..1 unified adherence; None => the backend's native default", default=None, stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'sample_rate': Affordance(name='sample_rate', type=<class 'int'>, description='Requested rate (Hz); the actual rate is measured and recorded', default=None, stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'seed': Affordance(name='seed', type=<class 'int'>, description='Reproducibility (capture in provenance)', default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=None), 'steps': Affordance(name='steps', type=<class 'int'>, description='Diffusion/flow steps', default=None, stage='generate', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'video': Affordance(name='video', type=<class 'object'>, description='The picture to sound (a URL, a RemoteVideo, a local path or bytes; keyed by content)', default=None, stage='generate', carries_meaning=True, choices=None, renamed_from=None, bounds=None)}#
Unified generation-stage parameters (generate backends map onto these).
- foley.base.ISO_COUNTRY_CODES: frozenset = frozenset({'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY', 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN', 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM', 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK', 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL', 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM', 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR', 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN', 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS', 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK', 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW', 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP', 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM', 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW', 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM', 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF', 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW', 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI', 'VN', 'VU', 'WF', 'WS', 'YE', 'YT', 'ZA', 'ZM', 'ZW'})#
The ISO 3166-1 alpha-2 country codes (the 249 officially assigned).
- class foley.base.IntendedUse(commercial=True, publish=True, redistribute_standalone=False, will_train=False, can_attribute=True, revenue_usd=0, allow_voice_or_trademark=False, territory=None)[source]#
Bases:
SerializableMixinWhat the caller intends to do with a sound; consumed by
keep().- territory: Optional[str] = None#
Where the sound is used (ISO 3166-1 alpha-2, e.g.
"US";"UK"reads as"GB"), or"WORLD"(WORLDWIDE: online publishing reaches every country). Only a licence that excludes territories asks (foley.licensing.LICENSE_EXCLUDED_TERRITORIES); for one,Nonefails closed, and so does"WORLD".
- class foley.base.Layer(*values)[source]#
-
Mix layer (shared by
SoundEventnow andTimelineItemlater).
- class foley.base.LicenseRecord(source, source_id=None, source_url=None, acquisition_method=AcquisitionMethod.user, retrieved_at=None, adapter_version=None, content_sha256=None, license_id='unknown', license_name=None, license_version=None, license_url=None, rights_holder=None, creator_name=None, creator_url=None, commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=False, modification_ok=False, ai_training_ok=False, ai_training_scope=None, gen_ai_preference=None, revenue_cap_usd=None, license_basis=None, license_basis_confidence=None, vendor_trains_on_output=None, terms_notes=list(), requires_attribution=False, attribution_text=None, notice_text_required=None, transformations=list(), derived_from_license_ids=list(), is_ai_generated=False, generator_model=None, generator_version=None, generation_prompt=None, generation_prompt_used=None, generation_seed=None, generation_params=dict(), watermark=None, vendor_watermark=None, c2pa_manifest_ref=None, contains_recognizable_voice=False, potential_trademark=False, disclosure_recommended=False, rights_verified=False, verified_at=None, schema_version=1)[source]#
Bases:
SerializableMixinPer-sound rights + provenance. SSOT for BOTH
keep()and storage mode.The derived permission flags default fail-closed here (the bare-record baseline) — with one deliberate exception:
embed_in_derivative_okdefaultsTrue(the normal case for a licensed sound). That is not a live bypass:keep()checksrights_verifiedfirst, so an unverified record is rejected regardless. Populate the flags from thelicense_idviafoley.licensing.apply_license_flags(source overrides win). Never hand-set the derived flags — always route through the policy layer.- property generation_reproducible: Optional[bool]#
Trueiff a seed was recorded.Nonefor a sound that was not generated (by a model, or procedurally). A backend with no seed (ElevenLabs, Sonilo) records none, so its clips readFalserather than carrying a seed that would reproduce nothing (#75). A seed is necessary, not sufficient: a hosted endpoint can change its model behind the same id. A clip whosegeneration_paramssaybit_exactisFalse(pyfxr’s noise waveform, #76) isFalse: the same seed and params render different bytes. A prompt the backend rewrote (expand_prompt) isFalsetoo: replaying it runs the rewrite again.- Type:
Whether this generated clip can be made again
- foley.base.MASTER_PROFILES: dict[str, MasterProfile] = {'broadcast_atsc': MasterProfile(target_lufs=-24.0, true_peak_db=-2.0, lra=7.0, max_limiting_db=6.0), 'broadcast_ebu': MasterProfile(target_lufs=-23.0, true_peak_db=-1.0, lra=7.0, max_limiting_db=6.0), 'podcast': MasterProfile(target_lufs=-16.0, true_peak_db=-1.0, lra=11.0, max_limiting_db=6.0), 'streaming': MasterProfile(target_lufs=-14.0, true_peak_db=-1.0, lra=11.0, max_limiting_db=6.0)}#
The named delivery targets (report 06 §5.2).
resolve_master()maps a profile name to one of these; these values are the SSOT so no LUFS literal hides in code.
- class foley.base.MasterProfile(target_lufs=-16.0, true_peak_db=-1.0, lra=11.0, max_limiting_db=6.0)[source]#
Bases:
SerializableMixinLoudness master target — the delivery spec as data, not code (report 06 §5.2).
- max_limiting_db: float = 6.0#
How far (dB) the master’s loudness stage lets the sample peak run over
true_peak_dbfor the default lookahead limiter to take back (it may take off a little more, the inter-sample overshoot of those peaks). 0 restores a static, whole-program master. Transient foley (a door slam under narration) needs a few dB to reach the target at all (foley#91).
- class foley.base.MatchKind(*values)[source]#
-
HOW a
Placement’s anchor was resolved against the narration (#263).exact— the cue word was spoken as written;stem— a word sharing its stem (an inflection, or the spoken part of a compound cue);fuzzy— only a lexically similar word (it may be a false match:thunderlands on “under”);fallback— nothing matched (or there were no word timings), so the stored onset or the whole narration was used;absolute— the placement names no word to match (an absolute offset, or a bed with no cue spanning the narration).
- class foley.base.Placement(anchor=Anchor.absolute, ref=None, onset=0.0, pre_roll=0.0, duration=None, loop=False, match_kind=None)[source]#
Bases:
SerializableMixinWHERE/WHEN a clip sits — a symbolic anchor plus its resolved time (report 06 §6.3).
Filled by WEAVE’s aligner+anchor pass.
onsetis the resolved start in seconds (distinct from the sparseTimelineItem.onsetsymbolic string);pre_rollshifts the clip earlier so its salient transient — not its file start — lands on the anchor (report 06 §2.4).match_kindrecords how the anchor resolved (MatchKind), so a fuzzy or fallback placement is visible.
- class foley.base.Processing(gain_db=0.0, pan=0.0, distance=0.0, reverb_send=0.0, fade_in=0.008, fade_out=0.012, duck_bed=False)[source]#
Bases:
SerializableMixinHOW a clip sounds — all optional with identity defaults (report 06 §3, §6.3).
Every field is a no-op at its default, so a sparse item (no
processing) renders untouched; the mixer departs from dry/centered/full-level only when a field is set.
- foley.base.QUERY_AFFORDANCES: dict[str, Affordance] = {'audioset_label': Affordance(name='audioset_label', type=<class 'str'>, description='AudioSet ontology facet (rolls up children)', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'commercial_ok': Affordance(name='commercial_ok', type=<class 'bool'>, description='License filter shorthand', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'duration_range': Affordance(name='duration_range', type=<class 'tuple'>, description='(min_s, max_s)', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'filters': Affordance(name='filters', type=<class 'dict'>, description='Metadata predicates (SQL-style)', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'include_explicit': Affordance(name='include_explicit', type=<class 'bool'>, description='Also return explicit / sensitive results', default=False, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'include_pronunciations': Affordance(name='include_pronunciations', type=<class 'bool'>, description='Also return recordings of a person saying a word (#295, #319)', default=False, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'k': Affordance(name='k', type=<class 'int'>, description='Number of results', default=10, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'kind': Affordance(name='kind', type=<class 'str'>, description='Media kind: sfx | music', default='sfx', stage='query', carries_meaning=True, choices=('sfx', 'music'), renamed_from=None, bounds=None), 'license': Affordance(name='license', type=<class 'str'>, description='Explicit license id constraint', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'min_snr': Affordance(name='min_snr', type=<class 'float'>, description='QC filter: min SNR dB', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'page': Affordance(name='page', type=<class 'int'>, description='Results page (1-based; k per page)', default=1, stage='query', carries_meaning=True, choices=None, renamed_from=None, bounds=None), 'query': Affordance(name='query', type=<class 'str'>, description='Natural-language query', default=None, stage='query', carries_meaning=False, choices=None, renamed_from='text', bounds=None), 'rerank': Affordance(name='rerank', type=<class 'bool'>, description='Apply second-stage rerank', default=False, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'semantic_text': Affordance(name='semantic_text', type=<class 'str'>, description='Query for CLAP semantic space', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'similar_to': Affordance(name='similar_to', type=<class 'str'>, description='Source sound id: more like this one (a source that has it)', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None), 'sort': Affordance(name='sort', type=<class 'str'>, description='Result order', default='relevance', stage='query', carries_meaning=False, choices=('relevance', 'newest', 'popular', 'duration'), renamed_from=None, bounds=None), 'sources': Affordance(name='sources', type=<class 'list'>, description='Restrict an aggregator to these of its providers', default=None, stage='query', carries_meaning=True, choices=None, renamed_from=None, bounds=None), 'ucs_category': Affordance(name='ucs_category', type=<class 'str'>, description='UCS CatID facet', default=None, stage='query', carries_meaning=False, choices=None, renamed_from=None, bounds=None)}#
Unified query-stage parameters (search / find / filter surface).
- foley.base.SUSPECT_MATCH_KINDS: dict[MatchKind, str] = {MatchKind.fallback: 'no spoken word (placed at a fallback onset)', MatchKind.fuzzy: 'only a similar word (it may be the wrong one)'}#
The match kinds whose sound may not sit on its cue word, and why — the SSOT the weave notes and the taste eval both flag (#263).
- class foley.base.SerializableMixin[source]#
Bases:
objectAdds
to_dict/to_json/from_dict/from_jsonto a dataclass.Stdlib-only, DRY, no-magic (de)serialization. Every SSOT dataclass below inherits this instead of hand-rolling per-class encoders/decoders.
- classmethod from_dict(d)[source]#
Reconstruct an instance from a plain dict.
Enum fields and nested dataclasses are coerced via
_decode(). Unknown keys are ignored (forward-compatible); missing keys fall back to field defaults.- Parameters:
d (
dict) – A plain dict (typically fromto_dict()orjson.loads).- Return type:
- classmethod from_json(s)[source]#
Reconstruct an instance from a JSON string.
- Parameters:
s (
str) – A JSON string (typically fromto_json()).- Return type:
- class foley.base.SoundDesignTimeline(items=list(), run_manifest_ref=None, transcript_ref=None, schema_version=1, narration_ref=None, word_timeline=list(), master=MasterProfile(), sfx_gain_db=0.0)[source]#
Bases:
SerializableMixinThe editable, re-renderable sound-design plan — the SELECT→WEAVE bridge and render SSOT.
SELECT (#7) emits the SPARSE form (just
items+ the run/transcript joins) viafoley.agent.plan(). WEAVE (#8) grows it additively:narration_refbinds the voice audio,word_timelinecaches the forced alignment (the reproducible seed),mastercarries the loudness target, and each item gains its resolvedPlacement/Processing.render(timeline, library)is then a PURE function of this data + the library, so editing any field and re-rendering reproduces exactly that change.run_manifest_ref==foley.obs.RunManifest.run_id(the reserved #8plan_refjoin).
- class foley.base.SoundEvent(query, layer=Layer.sfx_fg, diegetic=True, salience=Salience.medium, onset=None, loop=False, ucs_catid=None, audioset=list(), era_place=None)[source]#
Bases:
SerializableMixinOne salient, physically-audible event decomposed from a passage.
- class foley.base.SoundRecord(id, content_sha256=None, hash_algo='sha256', uri=None, storage_mode=StorageMode.by_reference, archive_format=None, source_sample_rate=None, source_bit_depth=None, license=<factory>, caption=None, tags=list(), ucs_category=None, ucs_subcategory=None, audioset_labels=list(), duration_s=None, sample_rate=None, channels=None, loudness_lufs=None, format=None, qc=None, embedding_model=None, embedding_dim=None, embedding_ref=None, named_cue=None, schema_version=1)[source]#
Bases:
SerializableMixinCanonical SSOT per sound.
Audio bytes + CLAP vector live in SEPARATE stores keyed by the same id; this record holds a content-hash
uri, never raw bytes.
- class foley.base.StorageMode(*values)[source]#
-
How a sound’s bytes are held (DERIVED from
license.cache_bytes_ok).
- foley.base.TERRITORY_ALIASES = {'EL': 'GR', 'UK': 'GB'}#
the UK’s common one and the EU’s code for Greece.
- Type:
Spellings that name a country by another code
- class foley.base.TimelineItem(clip_ref, onset=None, gain=0.0, layer=Layer.sfx_fg, loop=False, id=None, placement=None, processing=None, event=None, enabled=True)[source]#
Bases:
SerializableMixinOne placed sound on the sound-design timeline — sparse seed + resolved render fields.
SELECT (#7) sets only the sparse flat fields (
clip_ref·onset·gain·layer·loop); WEAVE (#8) additively fillsid/placement/processing(and may carry the originatingeventfor provenance).enabledis a non-destructive mute. The sparse flat fields are never removed — they stay SELECT’s SSOT input; the render reads the resolvedplacement/processing(falling back to the flat fields when those are absent).
- class foley.base.Verdict(match, confidence, reason='', level=VerifyLevel.clap)[source]#
Bases:
SerializableMixinThe result of one verification rung for a candidate.
- class foley.base.VerifyLevel(*values)[source]#
-
Which rung of the verification ladder produced a
Verdict.
- foley.base.WORLDWIDE = 'WORLD'#
The territory of a sound used everywhere (online publishing reaches every country): a licence that excludes any territory refuses it (#175).
- foley.base.check_edit_args(op, affordances, *, clip_s=None, limits=None, floors=None, bounds=None)[source]#
Raise
ValueErrorunlessaffordancesare a valid call of the editop.Checked before anything is paid for: the op is known, its required parameters are given, it is given no other op’s parameters, each number is within its
Affordance.boundsand the backend’s own range (limits: name -> max;floors: name -> min), eachorderedpair is increasing, and a time into the source (EditOp.within_clip) does not pass its end (clip_s, when known).boundsare the backend’s limits on what the parameters make (a config’sedit_limits, each a(lo, hi)pair, eitherNone):clip_sthe source clip’s length,span_seachorderedwindow’s length,output_sthe output’s length (EditOp.output_seconds()). A length that cannot be read is not checked.>>> check_edit_args("inpaint", {"inpaint_start_s": 1.0, "inpaint_end_s": 2.5}) >>> check_edit_args("inpaint", {"inpaint_start_s": 1.0}) Traceback (most recent call last): ... ValueError: the inpaint edit needs inpaint_end_s= >>> check_edit_args("extend", {"extend_before_s": 0}) Traceback (most recent call last): ... ValueError: the extend edit needs one of extend_before_s=, extend_after_s= above 0 >>> check_edit_args("inpaint", {"inpaint_start_s": 1, "inpaint_end_s": 9}, clip_s=4) Traceback (most recent call last): ... ValueError: inpaint_end_s=9 is past the end of the 4 s source clip >>> check_edit_args("extend", {"extend_after_s": 5}, clip_s=58, ... bounds={"output_s": (None, 60)}) Traceback (most recent call last): ... ValueError: the extend edit's output is 63 s; this backend takes 60 s at most
- Return type:
- foley.base.checked_layers(layers)[source]#
layers(names orLayermembers) as a set of members, checked up front so a typo raises before any paid call (reeleehq/foley#316). A single name is one layer, not its letters;NonestaysNone(every layer).>>> checked_layers(["ambience", Layer.sfx_fg]) == {Layer.ambience, Layer.sfx_fg} True >>> checked_layers("ambience") == {Layer.ambience} True >>> checked_layers({"ambiance"}) Traceback (most recent call last): ... ValueError: 'ambiance' is not a mix layer; the layers are voice, sfx_fg, ambience, stinger, music
- foley.base.normalize_territory(territory)[source]#
territoryas an ISO 3166-1 alpha-2 code (orWORLDWIDE),Nonewhen unstated.>>> normalize_territory(" uk "), normalize_territory("EL"), normalize_territory("") ('GB', 'GR', None) >>> normalize_territory("world") 'WORLD'
- Raises:
ValueError – If it is not a country code (a name, an alpha-3 code, a region): a licence gate cannot judge what it cannot read.
- Return type:
- foley.base.reject_renamed(names, vocabulary=None)[source]#
Raise
TypeErrorif any ofnamesis an affordance’s old spelling.vocabularydefaults toGENERATION_AFFORDANCES; the old names come from eachAffordance’srenamed_from.>>> reject_renamed(["prompt", "duration_s"]) >>> reject_renamed(["duration"]) Traceback (most recent call last): ... TypeError: duration= was renamed duration_s=
- Return type:
- foley.base.resolve_master(master)[source]#
Resolve a master spec (profile name, explicit profile, or
None) to aMasterProfile.- Parameters:
master (
Union[str,MasterProfile,None]) – AMASTER_PROFILESkey (e.g.'podcast'), an explicitMasterProfile, orNone(-> the podcast default).- Return type:
- Returns:
The resolved
MasterProfile.- Raises:
ValueError – If
masteris an unknown profile name.