foley.weave.align#
Forced-alignment adapters — the Aligner seam’s fake default + WhisperX real impl.
Forced alignment takes narration audio and its known transcript and returns
word-level timestamps (report 06 §2). foley ships two implementations behind the
Aligner seam, mirroring
foley.agent.decompose’s fake/real discipline exactly:
FakeAligner— the deterministic, torch-free default: it evenly spaces the transcript’s words across the clip’s duration. No model, no network, fully reproducible — so hermetic CI (and any bare install) gets a usableword_timelinewith zero heavy dependencies.WhisperXAligner— the real ≈±50 ms impl behindfoley[align](whisperx+torch), lazy-imported inside its method soimport foley.weavestays dol-only.
_default_aligner auto-upgrades to WhisperX when foley[align] is installed,
else falls back to the fake — the progressive-disclosure rule.
Module Attributes
Fallback speaking cadence used only when the clip's duration is unknown (empty audio); otherwise |
|
WhisperX runs alignment at 16 kHz mono (its wav2vec2 CTC model's native rate). |
Functions
|
|
Classes
Deterministic, torch-free |
|
|
The real ≈±50 ms |
- class foley.weave.align.FakeAligner[source]#
Bases:
objectDeterministic, torch-free
Aligner— evenly spaces the transcript’s words.The hermetic default: given a transcript, it returns one
{'word','start','end'}per whitespace token, spread uniformly across the clip’s duration (or atWORDS_PER_SECONDwhen the audio is empty). No transcript → an emptyword_timeline(the render then falls back to absolute anchors).
- foley.weave.align.WHISPERX_SAMPLE_RATE: int = 16000#
WhisperX runs alignment at 16 kHz mono (its wav2vec2 CTC model’s native rate).
- foley.weave.align.WORDS_PER_SECOND: float = 2.5#
Fallback speaking cadence used only when the clip’s duration is unknown (empty audio); otherwise
FakeAlignerspreads words across the real audio duration so its timings are audio-length-aware.
- class foley.weave.align.WhisperXAligner(*, model_size='small', device='cpu', batch_size=16)[source]#
Bases:
objectThe real ≈±50 ms
Aligner(foley[align]) — faster-whisper ASR + wav2vec2 CTC.Lazy-imports
whisperxinsideword_timeline()soimport foley.weavestays dol-only. Transcribes (if no transcript) then force-aligns at 16 kHz mono.- Parameters: