foley.weave.protocols#
The structural DI seams of the WEAVE stage — Aligner / ApplyStrategy.
Two @runtime_checkable typing.Protocols (PEP 544), each a
behaviour-free, open-closed contract that every implementation (the deterministic
fake and the heavy real impl) satisfies. They are dependency-injected into
foley.weave.render() / foley.weave.weave() by keyword
(aligner= / apply_strategy=), defaulting to a hermetic fake / pure-numpy
impl when the heavy extra (foley[align]) is absent — mirroring
foley.agent.protocols exactly.
Stdlib-only: the base shapes are imported under TYPE_CHECKING only, so
importing this module pulls no heavy dependency and keeps import foley and
import foley.weave dol-only.
Classes
|
Narration audio + its transcript → word-level timestamps (forced alignment). |
|
How ONE hydrated item's clip is placed onto its layer bus (report 10 §4.2). |
- class foley.weave.protocols.Aligner(*args, **kwargs)[source]#
Bases:
ProtocolNarration audio + its transcript → word-level timestamps (forced alignment).
Returns a
word_timeline: a list of{'word': str, 'start': float, 'end': float}dicts (seconds), the raw material the anchor heuristics (report 06 §2.4) turn into sample onsets. The default is the deterministic, torch-freeFakeAligner(evenly spaces the transcript’s words across the clip);WhisperXAligneris the real ≈±50 ms impl behindfoley[align].
- class foley.weave.protocols.ApplyStrategy(*args, **kwargs)[source]#
Bases:
ProtocolHow ONE hydrated item’s clip is placed onto its layer bus (report 10 §4.2).
The seam that lets the render swap placement policy without touching the render loop: the default
FullRenderapplies the full per-item DSP chain (fit-duration → gain/pan/distance/reverb → declick → overlay), whilePlaceOnlydoes a dry declicked overlay (fast preview / DSP-free fallback).itemis already anchor-resolved (item.placement.onsetis in seconds);busandclipare stereofloat32working arrays atsample_rate.