Skip to main content

Module sfxgen

Module sfxgen 

Source
Expand description

SFX asset generation and stem placement โ€” the generation half of sfx_common.py, plus the backends of sfx_backends.py.

Two phases, as in Python: every unique effect key gets a shared asset in SFX/ (copied from its declared source, rendered as silence, or generated by a backend), then each script entry gets a copy of that asset under its sequence-numbered stem name. A manifest in the stems directory records what was placed, with a timestamped snapshot per run.

Structsยง

ElevenLabsBackend
MMAudioBackend
MMAudio via mmaudio_worker.py (CC BY-NC 4.0 weights).
MMAudioOptions
PlanEntry
One direction entry matched to an effect (load_sfx_entries output).

Constantsยง

MMAUDIO_COMMENT
MMAUDIO_LICENCE_ERROR ๐Ÿ”’

Traitsยง

SfxBackend
SfxBackend: generate_to(out_path, prompt, duration, influence) + close().

Functionsยง

content_key ๐Ÿ”’
copy2
shutil.copy2: contents, permission bits and timestamps.
default_influence ๐Ÿ”’
dry_run_sfx
dry_run_sfx(entries, config, stems_dir, sfx_dir=, backend_name=).
ensure_shared_sfx
ensure_shared_sfx(key, effect, sfx_dir, defaults, show=, backend=).
export_silence ๐Ÿ”’
AudioSegment.silent(duration).export(path, format="mp3").
file_nonempty
file_nonempty(path).
generate_sfx
generate_sfx(entries, config, stems_dir, sfx_dir=, start_from=, backend=).
load_sfx_entries
load_sfx_entries(script, sfx, max_duration, direction_types, local_only, sfx_dir).
make_sfx_backend
make_sfx_backend(name, ...). Ok(None) means the caller should exit with status 1 (the error is already logged, as sys.exit(1) does).
place_episode_stem
place_episode_stem(shared, stem) โ†’ whether it copied.
resolve_source_path
resolve_source_path(source): workspace-relative, NFC/NFD tolerant.
trim_audio_file ๐Ÿ”’
_trim_audio_file(path, seconds).
upsert ๐Ÿ”’
_sfx_manifest_upsert: update in place when the content key matches.
with_api_retries
Retry 429 / 5xx / transport failures five times, waiting 10 s, 20 s, โ€ฆ
write_atomic ๐Ÿ”’
Write bytes through a .tmp sibling and an atomic rename.

Type Aliasesยง

ContentKey ๐Ÿ”’