foley.sources.stable_audio.adapter#
Stable Audio Open 1.0 generate adapter — local diffusers inference.
Turns a natural-language prompt into a GeneratedClip
via diffusers.StableAudioPipeline running on-device (report 02 §Stable Audio
Open). The model produces a 44.1 kHz stereo waveform (up to ~47 s); the adapter
encodes it to container bytes, which the foley.sources.generate.generate()
façade stores by-value (the generation flywheel) through the shared
ingest_one() pipeline.
Load-bearing details verified against the diffusers docs + HF model card:
**The CFG kwarg is
guidance_scale``** (NOT ``cfg_scale), and it MUST be passed explicitly or the pipeline silently uses its own default 7.0. foley maps its unifiedprompt_influence(0..1) onto it linearly (1..15, declared in the config’scoerce);Nonesends the model’s own default, and a distilled checkpoint (native_defaults["distilled"]) always gets its native default.**Output is channel-first
(channels, samples)``** — transposed to the time-first ``(frames, channels)foley/soundfile convention before encoding.The sample rate is read off the pipeline (
pipe.vae.sampling_rate= 44100), never hardcoded.``loop`` and ``output_format`` have no native pipeline param (loop is a future WEAVE crossfade; format is the audio-write layer) — they warn-and-drop; the adapter never fabricates a pipeline kwarg.
torch / diffusers are imported lazily inside the methods (the
foley[stable-audio] extra), so import foley and source discovery stay
dol-only. The local-model DI seam is pipeline= (the analog of the hosted
adapters’ http=): inject a fake pipeline and no ML stack loads at all — the
whole adapter is testable with no torch. The adapter performs NO storage/library
access; the façade converges it on the shared ingest pipeline.
Module Attributes
Registry convention (arioso): the loader imports |
Classes
Registry convention (arioso): the loader imports |
|
|
Local Stable Audio Open 1.0 generate adapter (a |
- foley.sources.stable_audio.adapter.Adapter#
Registry convention (arioso): the loader imports
adapter.Adapter.
- class foley.sources.stable_audio.adapter.StableAudioAdapter(config=None, *, pipeline=None)[source]#
Bases:
objectLocal Stable Audio Open 1.0 generate adapter (a
GenerateAdapter).- Parameters:
config (
Optional[dict]) – TheSOURCE_CONFIG(defaults to the module’s). Passed positionally by the registry’s lazy loader (the ariosoAdapter(config)convention).pipeline – An optional pre-built pipeline (the dependency-injection seam — a test injects a fake callable exposing
.vae.sampling_rate+.device; production omits it and the realdiffusers.StableAudioPipelinelazy-loads on first generation).
- generate(prompt, *, duration=None, prompt_influence=None, negative_prompt=None, steps=None, seed=None, loop=False, output_format='wav', **kw)[source]#
Generate a sound for
prompt; return its bytes + provisional candidate.- Parameters:
prompt (
str) – The natural-language sound description (required).duration (
Optional[float]) – Seconds (clamped to the model’s ~47.55 s max).Noneuses a sane 10 s default (NOT the 47.55 s maximum).prompt_influence (
Optional[float]) –0..1unified adherence, mapped linearly onto the nativeguidance_scale(1..15).None(default) sends the model’s own default (7.0 for Stable Audio Open 1.0); a distilled checkpoint ignores it with a note.negative_prompt (
Optional[str]) – Content to exclude (ignored by the model when guidance ≤ 1).steps (
Optional[int]) – Diffusion steps (nativenum_inference_steps); default 200.seed (
Optional[int]) – Reproducibility seed → a per-devicetorch.Generator; recorded in provenance.None→ non-deterministic (no torch import).loop (
bool) – No native param (a future WEAVE crossfade) — warn-and-drop.output_format (
str) – No native param (the audio-write layer) — warn-and-drop; the clip is archived as FLAC by ingest regardless.**kw – Extra/unknown affordances (warn-and-dropped).
- Return type:
- Returns:
A
GeneratedClip(origin=generated,license_id='Stability-Community',is_ai_generated=True,generation_seedcaptured).