Sfx Backends
src.xil_pipeline.sfx_backends
Pluggable backends for SFX / music / ambience asset generation.
The pipeline historically generated every non-silence sound effect through the
ElevenLabs Sound Effects API. This module introduces a thin :class:SfxBackend
adapter so the shared generation path in :mod:xil_pipeline.sfx_common no longer
talks to the ElevenLabs client directly. Two backends are provided:
- :class:
ElevenLabsSfxBackend— wrapsclient.text_to_sound_effects.convertwith stream-to-temp, atomic rename, and 429 / 5xx / network retry handling. - :class:
AudioLDM2SfxBackend— drives a local AudioLDM 2 Large diffusion model via a persistent worker subprocess (:mod:xil_pipeline.audioldm2_worker) in a dedicatedvenv-audioldm2virtualenv. Free, GPU-accelerated, no API credits.
Both expose the same minimal contract::
backend.generate_to(out_path, prompt, duration_seconds, prompt_influence)
backend.close()
Use :func:make_sfx_backend to construct the right backend from a CLI flag.
SfxBackend
Bases: Protocol
Minimal contract for a sound-effect generation backend.
Source code in src/xil_pipeline/sfx_backends.py
generate_to
Generate audio for prompt and write it to out_path.
ElevenLabsSfxBackend
SFX backend backed by the ElevenLabs Sound Effects API.
Wraps client.text_to_sound_effects.convert with the streaming
download, atomic temp-file rename, and retry behaviour that previously
lived inline in :func:xil_pipeline.sfx_common.ensure_shared_sfx.
Retries 429 (rate limit), 5xx (server error), and network transport
errors up to five times with linear backoff (10s, 20s, …).
Source code in src/xil_pipeline/sfx_backends.py
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
__init__
generate_to
Source code in src/xil_pipeline/sfx_backends.py
AudioLDM2SfxBackend
SFX backend backed by a local AudioLDM 2 Large diffusion model.
Adherence to the prompt is governed by guidance/steps (configured
at construction), so the ElevenLabs-specific prompt_influence argument
is accepted for interface compatibility but ignored.
Source code in src/xil_pipeline/sfx_backends.py
__init__
generate_to
Source code in src/xil_pipeline/sfx_backends.py
make_sfx_backend
make_sfx_backend(name: str, client=None, *, audioldm2_python: str | None = None, device: str = 'cuda', guidance: float = 3.5, steps: int = 200, negative_prompt: str = 'low quality, noise') -> SfxBackend
Construct an :class:SfxBackend for the given backend name.
Parameters:
-
name(str) –"elevenlabs"or"audioldm2". -
client–ElevenLabs client (used only for
"elevenlabs"). -
audioldm2_python(str | None, default:None) –Explicit path to the venv-audioldm2 Python; auto-detected when
None. -
device(str, default:'cuda') –"cuda"(default) or"cpu"for AudioLDM 2. -
guidance(float, default:3.5) –AudioLDM 2
guidance_scale. -
steps(int, default:200) –AudioLDM 2
num_inference_steps. -
negative_prompt(str, default:'low quality, noise') –AudioLDM 2 negative prompt.
Returns:
-
SfxBackend–A ready-to-use backend instance.