foley.weave#
WEAVE — the compositor façade: narration + timeline → a finished, editable mix.
weave() is the headline WEAVE entrypoint (report 06 §7, issue #8): it resolves the
master profile, binds the narration, opens a foley.obs.run('weave') scope, and
drives the PURE render() pipeline
(align → anchor → mix → master → render), then wraps the result with credits, SDH
captions, and a fail-safe provenance re-assertion over the mastered mix. It returns
a WeaveResult: the mastered audio, the hydrated re-renderable
SoundDesignTimeline (the reproducible seed), a
Credits, WebVTT + SRT SDH captions, the master report, and
the run-artifact join.
Discipline (mirrors the rest of foley): the whole package is import-time dol-only (numpy / mixing.loudness / whisperx / opentimelineio / audioseal / c2pa are all function-local), the aligner and per-item strategy are injectable DI seams with deterministic defaults, and provenance re-assertion never raises — the C2PA content-credential sidecar is always emitted; the AudioSeal watermark and the (deferred) signed + embedded C2PA manifest are best-effort no-ops when their extras/cert are absent.
Module Attributes
The synthetic library key WEAVE binds raw narration audio under (when the caller passes audio rather than a ref already in the library). |
Functions
|
Weave the chosen sounds under |
|
Render |
|
Resolve every item's anchor + fill processing/id, returning a NEW timeline. |
|
Parse SELECT's sparse symbolic |
|
Resolve a |
|
Resolve a |
|
Return the |
|
Swap an item's clip (keeping its placement/processing) — a NEW timeline. |
|
Shift an item's resolved onset by |
|
Set an item's processing gain (dB, voice-relative) — a NEW timeline. |
|
Non-destructively mute/unmute an item — a NEW timeline. |
|
Set the timeline's master profile (name or |
|
Render the timeline's SFX cues as a WebVTT SDH caption file (report 06 / issue #8). |
|
Render the timeline's SFX cues as an SRT SDH caption file (report 06 / issue #8). |
|
Export |
|
Export |
|
Export |
|
Re-assert provenance over the mastered mix — watermark + C2PA sidecar (fail-safe). |
|
Report which optional WEAVE system binaries are available ( |
|
Check the optional system deps and return a per-dep status + guidance report. |
|
Speech lines heard through a radio/TV/PA/phone over a bed, looped for a scene (#108). |
Classes
|
The output of |
|
The output of |
Per-layer render memo ( |
|
|
Default |
Dry |
|
|
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). |
Deterministic, torch-free |
|
|
The real ≈±50 ms |
|
An |
|
Montreal Forced Aligner ( |
|
aeneas (TTS + DTW) behind the |
|
Loudness master target — the delivery spec as data, not code (report 06 §5.2). |
|
What the master stage did — a JSON-serialisable audit row for the run-artifact. |
|
A rendered broadcast bed: the audio and the rights of everything in it. |
Exceptions
A source whose rights do not allow it into a broadcast bed (refused, fail-closed). |
- class foley.weave.AeneasAligner(*, python='/opt/hostedtoolcache/Python/3.12.16/x64/bin/python', languages=None, timeout=None, runner=<function run>)[source]#
Bases:
objectaeneas (TTS + DTW) behind the
Alignerseam, one fragment per word.Light and language-broad (anything espeak speaks), coarser than MFA at word level, and AGPL-licensed: foley runs it as a separate program and never imports it. aeneas pins old dependencies, so it often lives in its own virtualenv; point
pythonat that interpreter.- Parameters:
python (
str) – A Python interpreter withaeneasinstalled (default: this one).languages (
Optional[Mapping[str,str]]) – foley language code → aeneas task language (defaultAENEAS_LANGUAGES).timeout (
Optional[float]) – Seconds before the run is abandoned (default: none).runner (
Callable[...,CompletedProcess]) – Runs the command (defaultsubprocess.run).
- class foley.weave.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.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. A strategy with settings that change its output should expose them as acache_keystring: theRenderCachekeys on it (default: the class name).
- class foley.weave.BroadcastBed(audio, sr, license, sources, treatment, notes=list(), sound_id=None)[source]#
Bases:
objectA rendered broadcast bed: the audio and the rights of everything in it.
- audio#
Mono
float32samples.- Type:
ndarray
- license#
The mix’s rights (
broadcast_license()): the bed’s narrowed to the speech’s, never wider than either.- Type:
- sources#
(bed, speech)provenance as given: the bed’sSoundRecord(library or generated) orLicenseRecord, and the speech’s licence (Noneif not given). For the credit line usecredits, which reads both offlicense.- Type:
- notes#
What the caller should know (unmeasurable levels, missing rights, the bed generation’s own notes, the ingest’s).
- Type:
- exception foley.weave.BroadcastRefusal[source]#
Bases:
ValueErrorA source whose rights do not allow it into a broadcast bed (refused, fail-closed).
- class foley.weave.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).
- class foley.weave.FullRender(*, level_clips=True)[source]#
Bases:
objectDefault
ApplyStrategy— the full per-item DSP chain (report 06 §3-4).fit-duration(loop/trim) →level(measured loudness to the reference,foley.level.reference_gain_db(), on what will be heard) → distance → reverb send → constant-power pan → declick → gain (base layer level + itemgain_db) → overlay at the resolved onset. Levelling first means the layer gains act on clips of equal loudness, whatever level each was generated or recorded at (#111);level_clips=Falserenders the clips as stored.- apply(item, bus, clip, *, sample_rate)[source]#
Fit, process and overlay
clipontobusforitem; return the new bus.- Return type:
ndarray
- property cache_key: str#
What distinguishes this strategy’s output in
RenderCachekeys.
- class foley.weave.MFAAligner(*, mfa='mfa', models=None, extra_args=(), timeout=None, runner=<function run>)[source]#
Bases:
objectMontreal Forced Aligner (
mfa align_one) behind theAlignerseam.Kaldi-based, MIT-licensed, and among the most accurate open aligners on read speech. It needs a pronunciation dictionary and an acoustic model per language, downloaded once (
mfa model download ...). MFA normalises the text (case, punctuation, clitics) and writes<unk>for a word missing from its dictionary (numbers too); the timeline still holds the transcript’s own words (onto_transcript()), an unknown one timed by its<unk>.- Parameters:
mfa (
str) – Themfaexecutable: a name onPATH, or a path into a conda env (no need to activate it; itsbinis put on the program’sPATH).models (
Optional[Mapping[str,tuple[str,str]]]) –{language: (dictionary, acoustic_model)}, names or paths asmfa align_onetakes them (defaultMFA_MODELS).extra_args (
Sequence[str]) – Moremfa align_oneoptions (("--beam", "100")).timeout (
Optional[float]) – Seconds before the run is abandoned (default: none).runner (
Callable[...,CompletedProcess]) – Runs the command (defaultsubprocess.run).
- class foley.weave.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.weave.MasterReport(target_lufs, input_lufs, output_lufs, true_peak_dbtp, true_peak_ceiling_db, gain_db, limited, engine)[source]#
Bases:
objectWhat the master stage did — a JSON-serialisable audit row for the run-artifact.
- foley.weave.NARRATION_REF: str = '__foley_narration__'#
The synthetic library key WEAVE binds raw narration audio under (when the caller passes audio rather than a ref already in the library).
- class foley.weave.PlaceOnly[source]#
Bases:
objectDry
ApplyStrategy— declicked placement, no gain/pan/distance/reverb.The fast preview / DSP-free fallback path: fit-duration → declick → overlay at the resolved onset, at unity gain.
- class foley.weave.RenderCache[source]#
Bases:
dictPer-layer render memo (
bus_hash -> stereo bus array) for incremental re-render.
- class foley.weave.RenderResult(audio, sr, timeline, master_report, buses=dict(), alignment=None)[source]#
Bases:
objectThe output of
render(): the mastered mix + the hydrated (re-renderable) timeline.
- class foley.weave.SegmentedAligner(starts, segments, *, base=None)[source]#
Bases:
objectAn
Alignerfor narration whose segments start at known offsets.Splits the transcript’s words by segment (each segment’s word count), aligns each piece with
baseagainst that segment’s slice of the audio, and adds the slice’s start to the timings. Segmentispansstarts[i]tostarts[i + 1]; the last runs to the end of the audio; a segment with no words is skipped. Words keep the transcript’s order, so anchors resolve exactly as with a whole-file aligner.baseis called once per segment:WhisperXAlignerloads its models once and reuses them, but a subprocess aligner (MFAAligner,AeneasAligner) starts one process per segment.basemust align the audio it is given: one that returns precomputed whole-file timings should be passed toweave(aligner=)directly, not wrapped.- Parameters:
starts (
Sequence[float]) – Each segment’s start, in seconds into the narration audio (one per segment, non-decreasing).segments (
Sequence[str]) – The segments’ texts; only their word counts are used, to split the transcriptword_timelinereceives.base (
Optional[Aligner]) – The aligner run on each slice (default: WhisperX if installed, else the fake, chosen at first use).
- spans(duration, *, sample_rate)[source]#
Each segment’s
(start, end)in audio ofdurationseconds (ValueErrorif a segment with words starts at or past the end, or spans no sample).
- class foley.weave.WeaveResult(audio, sr, timeline, credits, captions_vtt, captions_srt, master_report, run_manifest_ref=None, content_credential=None, watermark=None, notes=list(), alignment=None)[source]#
Bases:
objectThe output of
weave()— the v1 Definition-of-Done deliverable.A mastered mix + an editable, re-renderable timeline + credits + SDH captions + a reproducible run-artifact join, plus the fail-safe provenance re-assertion.
- class foley.weave.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. The loaded models are kept on the instance (per model size, device and language), so aligning many clips, or aSegmentedAligner’s segments, loads them once.- Parameters:
- foley.weave.broadcast_bed(lines, *, bed=None, bed_prompt=None, treatment='am_radio', gap_s=0.6, duration=None, bed_under_speech_db=-12.0, duck_db=-10.0, duck_attack_s=0.02, duck_release_s=0.3, loop_speech=True, crossfade_s=0.05, ceiling_db=-1.0, speech_license=None, bed_license=None, tts=None, library=None, generate=None, generate_options=None, store=False, accept_ai_restricted=False, restamp=False, ingest_options=None, sr=None)[source]#
Speech lines heard through a radio/TV/PA/phone over a bed, looped for a scene (#108).
Everything that can be checked is checked before anything is paid for: the lines, the treatment, the bed’s form, and the rights of the speech and of a given bed (
mix_refusal()). Then the bed is generated (if prompted) and gated, and only then is the text spoken.- Parameters:
lines (
Sequence) – The spoken lines, in order: each an array atsr,(samples, sr), encoded bytes or a path; or text (astrthat is not a file), which goes throughtts=. Audio lines never go throughtts.bed – The bed: a library sound id, or its audio (any
linesform).bed_prompt (
Optional[str]) – Instead ofbed: a prompt forfoley.generate()(its budget, paid-generation consent and licence gate apply unchanged).treatment (
Treatment) – The device: aTREATMENTSname ('am_radio'default,'tv','pa','phone'), aTreatmentPreset, any(samples, sr) -> samplescallable (e.g. the fleet’s, oncemixinghas it), orNonefor dry. Applied to the whole program, crowd included.gap_s (
float) – Silence after each line (s).duration (
Optional[float]) – Length of the result (s);None: the lines once, with their gaps.bed_under_speech_db (
float) – The bed’s level under the speech (LU, integrated loudness), set before the treatment: the device’s compressor then narrows the gap a little, as a real one would.duck_db (
float) – How far the bed dips under each line relative to its level between lines (dB, negative): the bed sitsbed_under_speech_dbunder the speech while a line is spoken and swells up to-duck_dbback up in the gaps (short gaps fall short: ~9.2 dB with the defaults). Must be<= 0.0: a constant bed (the behaviour before #253).duck_attack_s (
float) – Time constant (s) of the bed’s dip into each line.duck_release_s (
float) – Time constant (s) of the bed’s swell after each line.loop_speech (
bool) – Repeat the lines to fillduration(else they play once).crossfade_s (
float) – Equal-power crossfade at each loop seam (s).ceiling_db (
float) – The result’s peak ceiling (dBFS), held whatever the treatment (mixing.loudness.limit_peaks()).speech_license (
Optional[LicenseRecord]) – The speech’s rights, as given (e.g. the TTS vendor’s terms).None: unknown, so the result’s rights fail closed.bed_license (
Optional[LicenseRecord]) – The rights of raw bed audio given asbed(a library or generated bed carries its own).tts (
Optional[Callable[[str],Union[ndarray,tuple,bytes,str,PathLike]]]) – Atext -> audiocallable that speaks text lines (no default: see the module docstring for voxy and an’s ElevenLabs provider).library – Where a bed id is looked up and a generated bed is stored (default: the process-wide library).
generate (
Optional[Callable]) – The bed generator (defaultfoley.generate(); a test seam).generate_options (
Optional[dict]) – Keyword arguments for it (backend,budget,duration_s,store, …; notlibrary).store (
bool) – Also ingest the result intolibraryby value, under its licence (both sources’ lineage recorded), sofoley.export_sound()and the credits work on it; its id is the result’ssound_id. Checked before anything is spent (store_refusal()): for a prompted bed, the speech’s rights and a named backend’s licence row before generating.accept_ai_restricted (
bool) – Consent to embed (index) the result when a source’s licence does not allow AI use (an AI-generated bed’s, a non-commercial speech’s). Without it such astore=Trueis refused, fail-closed. The consent is to embed and store only: the stored licence still forbids training.restamp (
bool) – Withstore=True: when a byte-identical sound is already stored with other credits, licence or lineage (a rerun with corrected credits), correct that stored record to this broadcast’s instead of refusing it (sound_id=None). Through the ingest’s re-stamp (foley.licensing.restamped_license()withremade=True): its credits and lineage are replaced, its rights only ever narrowed (a wider rerun is refused with a note, the record kept), and a licence that does not allow AI use still needsaccept_ai_restricted. Exports already made keep the credits they were exported with.ingest_options (
Optional[dict]) – More keywords forfoley.index.ingest.ingest_one()(tagger,do_supervised,thresholds, …) withstore=True.sr (
Optional[int]) – Working sample rate (defaultfoley.audio.WORKING_SAMPLE_RATE).
- Return type:
- Returns:
A
BroadcastBed.- Raises:
BroadcastRefusal – A source’s rights do not allow it in (
mix_refusal()), orstore=Truecannot store the result (store_refusal()).ValueError – Unusable lines, treatment, bed form or ingest options (before anything is spent).
KeyError – A bed id that is neither a file nor in the library.
- foley.weave.check_requirements(*, names=None, verbose=False)[source]#
Report which optional WEAVE system binaries are available (
shutil.which).- Parameters:
- Return type:
- Returns:
{name: is_available}. All-absent is fine — WEAVE degrades to its in-process path; the report just tells the user what each binary would unlock.
- foley.weave.export(timeline, *, fmt='auto')[source]#
Export
timelineas(format, text)— OTIO when available, else EDL.- Parameters:
timeline (
SoundDesignTimeline) – The timeline to export.fmt (
str) –'auto'(OTIO if installed, else EDL),'otio', or'edl'.
- Return type:
- Returns:
(format_name, serialized_text)— export always succeeds (EDL is the dependency-free fallback).
- foley.weave.hydrate(timeline, word_timeline=None)[source]#
Resolve every item’s anchor + fill processing/id, returning a NEW timeline.
Idempotent: an item that already carries a
Placementkeeps its symbolic anchor (a hand edit is never clobbered) but is re-resolved againstword_timelineso a re-recorded/re-aligned narration re-flows the SFX (report 06 §6.1); each placement records how its anchor matched (match_kind, #263).processingfalls back to the sparsegainandidto a stable content hash. The resolvedword_timelineis cached on the returned timeline (the reproducible seed).- Parameters:
timeline (
SoundDesignTimeline) – The (sparse or partially-resolved) timeline.word_timeline (
Optional[list]) – The forced alignment; defaults totimeline.word_timeline.
- Return type:
- Returns:
A hydrated copy with resolved placements, filled processing, stable ids.
- foley.weave.match_word(ref, word_timeline)[source]#
Return the
word_timelineentry best matchingrefand how it matched (#263).The one word resolver every anchor goes through, cheapest and surest first (earliest occurrence wins at each step): the phrase’s first token exactly; else a word sharing its stem (
_is_stem_match()); else the closest word by lexical (difflib) ratio over any token, among words at leastFUZZY_MIN_LENGTH_SHAREof its length (fuzzy, which can be a false match).(None, MatchKind.fallback)when nothing is close orrefis empty.>>> wt = [{"word": "The"}, {"word": "doors"}, {"word": "slammed."}] >>> [(w["word"], k.value) for w, k in (match_word(c, wt) for c in ("door", "slam"))] [('doors', 'stem'), ('slammed.', 'stem')] >>> match_word("zzzzz", wt) (None, <MatchKind.fallback: 'fallback'>)
- foley.weave.nudge(timeline, item_id, delta_s)[source]#
Shift an item’s resolved onset by
delta_sseconds — a NEW timeline.Resolves the item’s anchor against the timeline’s
word_timelinefirst, then shifts the resolved onset and pins the anchor toabsoluteso the manual offset survives a re-hydrate. This means nudging a still-symbolic (not-yet-hydrated) item on a timeline that carries alignment shifts from the item’s true resolved onset, not from 0. On a pre-alignment timeline with noword_timelinea word/sentence anchor is genuinely unresolvable, so there the shift is relative to 0 — hydrate/weave first for such items.- Return type:
- foley.weave.parse_symbolic_anchor(onset, *, layer=Layer.sfx_fg, loop=False)[source]#
Parse SELECT’s sparse symbolic
onsetstring into a resolved-laterPlacement.The anchor type follows the item’s role (report 06 §2.4): beds (
loop/ambience/music) span a sentence, stingers land on a scene boundary, and everything else is a word anchor; therefis the quoted phrase the sound lands on. ANoneonset means “no cue”: beds span from the start, one-shots sit atabsolute0. A bare number (defensive — SELECT is told never to emit one) is read as an absolute offset in seconds.- Parameters:
- Return type:
- Returns:
A
Placementwhoseonset(seconds) is resolved later byresolve_anchor()against theword_timeline.
- foley.weave.reassert_provenance(audio, sample_rate, records, *, asset_id, watermark=None, watermarker=None, sign_cert=None, provenance_store=None)[source]#
Re-assert provenance over the mastered mix — watermark + C2PA sidecar (fail-safe).
Watermarks the final mix when it carries AI-generated audio (or when
watermark=True), always writes a mix-level C2PA content-credential sidecar, and best-effort signs+embeds it. Never raises: any failure degrades to sidecar-only, so weaving is never blocked by provenance.- Return type:
- Returns:
{'audio', 'watermark', 'content_credential'}—audiois the (possibly watermarked) mix,watermarkthe AudioSeal meta orNone,content_credentialthe sidecar dict (always present unless credential construction itself failed).
- foley.weave.render(timeline, library, *, sr=48000, transcript=None, language=None, aligner=None, apply_strategy=None, cache=None, sfx_gain_db=None)[source]#
Render
timelineagainstlibraryinto a mastered mix (PURE, deterministic).- Parameters:
timeline (
SoundDesignTimeline) – The sound-design timeline (sparse or hydrated).narration_refmust resolve inlibrary;mastercarries the loudness target.library – A
foley.index.SoundLibrary(or a mapping of ref → audio).sr (
int) – Working/render sample rate in Hz.transcript (
Optional[str]) – Narration transcript for alignment whentimeline.word_timelineis empty (else alignment is skipped — the cached timeline is the seed).language (
Optional[str]) – The narration’s language code ("fr", …), passed to the aligner, which picks its models by it.None(default) sends none: the aligner’s own default (English for the built-ins) applies. Unused when the timeline already carries aword_timeline.aligner (
Optional[Aligner]) – TheAligner(default: WhisperX iffoley[align]installed, else the deterministic fake).apply_strategy (
Optional[ApplyStrategy]) – The per-itemApplyStrategy(defaultFullRender).cache (
Optional[RenderCache]) – An optionalRenderCachefor byte-identical incremental re-render (only changed layers recompute).sfx_gain_db (
Optional[float]) – The level of the whole sound-design bus (every non-voice layer, after ducking) relative to the narration, in dB, applied before mastering so the loudness target still holds (#292).None(default) uses the timeline’s ownsfx_gain_db(0 dB unless set: the mix as before, byte for byte); a number overrides it and is written on the returned timeline.-6.0sits the effects 6 dB further under the voice. Seecheck_sfx_gain_db()for the range.
- Return type:
- Returns:
A
RenderResult— the mastered stereo mix, the hydrated timeline (withword_timelinecached), and theMasterReport.
- foley.weave.resolve_anchor(placement, word_timeline, *, snap_pauses=False)[source]#
Resolve a
Placementto(onset_seconds, duration_seconds_or_None).The tuple view of
resolve_placement()(which also says how it matched).
- foley.weave.resolve_placement(placement, word_timeline, *, snap_pauses=False)[source]#
Resolve a
Placementagainst theword_timeline— a NEW placement.Dispatches on
placement.anchor(report 06 §2.4):absoluteuses the stored offset;wordfires on the trigger word;sentencespans its sentence (fillingdurationwhen unset — beds loop to fill it);scene/paragraphland on the boundary.pre_rollis then subtracted (clamped at 0), and — whensnap_pauses— the onset snaps to the nearest inter-word gap.match_kindrecords how the anchor matched (MatchKind): a cue with no word timings, or that matched no word, is afallbackat its stored onset (word) or the whole narration (span); a cue-less span isabsolute.- Parameters:
- Return type:
- Returns:
A copy with
onset(seconds),duration(filled only for a span anchor whosedurationwas unset) andmatch_kindresolved.
- foley.weave.set_gain(timeline, item_id, gain_db)[source]#
Set an item’s processing gain (dB, voice-relative) — a NEW timeline.
- Return type:
- foley.weave.set_master(timeline, master)[source]#
Set the timeline’s master profile (name or
MasterProfile) — a NEW timeline.- Return type:
- foley.weave.swap_clip(timeline, item_id, new_clip_ref)[source]#
Swap an item’s clip (keeping its placement/processing) — a NEW timeline.
- Return type:
- foley.weave.to_edl(timeline, *, title='foley SFX')[source]#
Export
timelineas a pure-stdlib CMX3600 EDL (deterministic, pinned ids).A lightweight interchange for DAWs; each enabled, placed item is one event with its clip name as the source comment. Always available (no dependency).
- Return type:
- foley.weave.to_otio(timeline, *, rate=25)[source]#
Export
timelineas an OpenTimelineIO JSON string (lazyfoley[weave]).One or more parallel tracks per non-voice layer: each enabled, placed item is a clip with an external media reference (by clip_ref), positioned at its resolved onset via a leading gap. Because a single OTIO track is sequential, two same-layer clips that overlap (or fall within a one-shot’s nominal window) would otherwise be pushed late — so overlapping clips spill onto sibling sub-tracks, keeping every clip at its true onset. Non-destructive, minimal-viable fidelity (tracks/clips/onsets; effects/markers are a later slice).
- Raises:
RuntimeError – If
opentimelineiois not installed.- Return type:
- foley.weave.to_srt(timeline, *, window_s=2.0)[source]#
Render the timeline’s SFX cues as an SRT SDH caption file (report 06 / issue #8).
- Return type:
- foley.weave.to_webvtt(timeline, *, window_s=2.0)[source]#
Render the timeline’s SFX cues as a WebVTT SDH caption file (report 06 / issue #8).
Each enabled, placed item becomes one
[bracketed]cue at its resolved onset.- Return type:
- foley.weave.toggle(timeline, item_id, enabled)[source]#
Non-destructively mute/unmute an item — a NEW timeline.
- Return type:
- foley.weave.verify_and_setup(*, names=None)[source]#
Check the optional system deps and return a per-dep status + guidance report.
Does not run installers (system-binary installs need the user’s consent and sudo). Surfaces the exact per-platform command so the user can opt in.
- foley.weave.weave(narration, timeline, *, master='podcast', library=None, transcript=None, language=None, aligner=None, apply_strategy=None, sr=48000, cache=None, watermark=None, watermarker=None, sign_cert=None, export_captions=True, provenance_store=None, intended_use=None, sfx_gain_db=None)[source]#
Weave the chosen sounds under
narrationinto a mastered, editable mix.The headline WEAVE façade (v1 DoD):
foley.weave(narration, timeline)→ align → anchor → mix → master → render, plus credits, SDH captions, and a reproducible run-artifact. Works out of the box with deterministic defaults (a fake aligner + pure-numpy DSP + in-process mastering); every model / seam is an optional keyword.- Parameters:
narration – The voice audio — a path / bytes / file-like / working ndarray, or a ref already keyed in
library.timeline (
SoundDesignTimeline) – The (sparse)SoundDesignTimelinefromfoley.plan(); WEAVE resolves anchors and fills processing.master (
Union[str,MasterProfile]) – AMASTER_PROFILESname ('podcast'default) or aMasterProfile.library – The
foley.index.SoundLibrary(or a mapping) holding the clips.transcript (
Optional[str]) – The narration transcript, for forced alignment (skipped when the timeline already carries aword_timeline).language (
Optional[str]) – The narration’s language code ("fr", …), passed to the aligner (MFA and aeneas pick their models by it; #225).None(default): the aligner’s own default, English for the built-ins. Liketranscript, it is unused when the timeline already carries aword_timeline(a note says so).aligner (
Optional[Aligner]) – The forced-alignment seam (default: WhisperX if installed, else fake).apply_strategy (
Optional[ApplyStrategy]) – The per-item placement seam (defaultFullRender).sr (
int) – Working/render sample rate in Hz.cache (
Optional[RenderCache]) – An optionalRenderCachefor incremental re-render.watermark (
Optional[bool]) –Trueforce a watermark,Falsenever,None(default) auto — watermark iff the mix contains AI-generated audio and AudioSeal is installed.watermarker – An injected watermarker (the DI seam; tests pass a fake).
sign_cert – A ready
c2pa.Signerfor the signed+embedded C2PA path (build one withfoley.provenance.make_c2pa_signer()); omit for the sidecar only.export_captions (
bool) – IfTrue(default), emit WebVTT + SRT SDH captions.provenance_store – An optional
MutableMappingto persist the C2PA sidecar.intended_use (
Optional[IntendedUse]) – The rights intent the mix is for (#208). Given, the gate is fail-closed: every enabled clip is judged by its record inlibrary(a clip with no record is refused), and so is the narration when it is a library ref; any refusal raises before rendering.None(default) renders as before but warns (FutureWarning) about whatDEFAULT_INTENDED_USEwould refuse: a future release gates by default.sfx_gain_db (
Optional[float]) – The level of the sound-design bus (everything but the narration) relative to the voice, in dB, applied before mastering so the loudness target still holds (#292): how a host honours a person’s level for a bed without re-mixing a second copy.None(default) keeps the timeline’s own level (0 dB unless set: the mix as before, byte for byte); a number overrides it and is written onresult.timeline, so re-weaving that timeline keeps it.-120mutes the effects; outside [-120, +40] dB raisesValueErrorbefore anything renders.
- Return type:
- Returns:
A
WeaveResult.- Raises:
LicenseRefusal – If
intended_useis given and refuses a clip or the narration (.refusednames each id and reason).
Modules
Forced-alignment adapters — the |
|
Symbolic-anchor → sample-onset heuristics — the SELECT→WEAVE timing bridge (report 06 §2.4). |
|
A diegetic broadcast bed: speech lines heard through a radio/TV/PA/phone over a bed (#108). |
|
Forced aligners run as external programs: Montreal Forced Aligner and aeneas (#43). |
|
Mastering — loudness-normalize + true-peak-limit the finished mix (report 06 §5). |
|
Pure-numpy mixing DSP — making a clip sit under the voice (report 06 §3). |
|
The structural DI seams of the WEAVE stage — |
|
Audience-reaction timing — a crowd answers an event, it does not coincide with it. |
|
System-dependency onboarding for WEAVE's optional upgrade paths (accompy-style). |
|
The sound-design timeline as an editable document — hydrate, edit, caption. |