import { type Fetch } from '../artwork/comfyui.js'; /** * Sound effects with Stable Audio 3 Small SFX on a local ComfyUI. The distilled model needs * 8 steps at CFG 1 and takes about 1.5 s per clip on an M1 Pro once loaded (the first clip * also loads ~3.5 GB of weights, about 20 s). It is small enough to run on the CPU. */ /** The two files of the Stable Audio 3 Small SFX setup and where to get them */ export declare const STABLE_AUDIO_SFX_MODELS: { readonly checkpoint: { readonly folder: "checkpoints"; readonly match: RegExp; readonly downloads: readonly [{ readonly file: "stable_audio_3_small_sfx.safetensors"; readonly note: "2.3 GB, distilled: 8 steps"; readonly url: "https://huggingface.co/Comfy-Org/stable-audio-3/resolve/main/checkpoints/stable_audio_3_small_sfx.safetensors"; }]; }; readonly textEncoder: { readonly folder: "text_encoders"; readonly match: RegExp; readonly downloads: readonly [{ readonly file: "t5gemma_b_b_ul2.safetensors"; readonly note: "1.2 GB"; readonly url: "https://huggingface.co/Comfy-Org/stable-audio-3/resolve/main/text_encoders/t5gemma_b_b_ul2.safetensors"; }]; }; }; type ModelKey = keyof typeof STABLE_AUDIO_SFX_MODELS; /** Valkyrie plays event audio on top of everything and does not stop it, so effects stay short */ export declare const MAX_SFX_SECONDS = 30; export declare const DEFAULT_SFX_SECONDS = 3; /** * ComfyUI's VAEDecodeAudio scales every clip to the same loudness (standard deviation 0.2), * and Stable Audio 3's transients reach 11-14 dB above full scale at that level, so they were * clipped when the FLAC was written. Lowering the level first keeps them; finishClip() * normalises the peak afterwards. */ export declare const HEADROOM_DB = -20; export interface StableAudioSettings { checkpoint: string; textEncoder: string; prompt: string; seconds: number; seed: number; steps: number; cfg: number; filenamePrefix: string; } /** Recommended sampling: the distilled model is built for 8 steps at CFG 1, "base" for 50 at CFG 7 */ export declare function recommendedAudioSampling(checkpoint: string): { steps: number; cfg: number; }; /** ComfyUI API-format workflow: Stable Audio 3 text-to-audio, as in ComfyUI's SA3 template */ export declare function buildStableAudioWorkflow(s: StableAudioSettings): Record; /** * ComfyUI decodes the SA3 audio VAE in bfloat16 by default (seen on Apple Silicon), and that * turns every clip into broadband noise: a gunshot sounded like static. --fp32-vae fixes it at * no real cost (the VAE is ~200 MB), and the diffusion model can stay in fp16 (same output). */ export declare const FP32_VAE_FLAG = "--fp32-vae"; export interface SoundStatus { reachable: boolean; url: string; error?: string; comfyuiVersion?: string; device?: string; models: Partial>; missing: ModelKey[]; /** ComfyUI was started with --fp32-vae; undefined when it does not report its arguments */ fp32Vae?: boolean; } /** Ready to generate: reachable, all models present, and the VAE not known to run in reduced precision */ export declare function soundReady(status: SoundStatus): boolean; /** Checks the ComfyUI server and which of the Stable Audio 3 SFX files it can load */ export declare function getSoundStatus(url?: string, fetchFn?: Fetch): Promise; /** Human-readable setup instructions for what getSoundStatus found missing */ export declare function soundSetupInstructions(status: SoundStatus): string; export interface GenerateSoundOptions { /** What the sound is: source, material, space, how it evolves */ prompt: string; /** Where to save the clip (.ogg) */ outputFile: string; /** Requested length in seconds; a silent tail is trimmed afterwards */ seconds?: number; seed?: number; steps?: number; /** Fade at the end in seconds (default 0.05) */ fadeOut?: number; url?: string; timeoutMs?: number; pollMs?: number; fetchFn?: Fetch; } export interface GenerateSoundResult { file: string; /** Length of the saved clip after trimming */ duration: number; bytes: number; seed: number; steps: number; checkpoint: string; /** Time taken, including loading the model on the first call */ seconds: number; } /** Generates one sound effect with Stable Audio 3 on a running ComfyUI and saves it as OGG Vorbis */ export declare function generateSound(opts: GenerateSoundOptions): Promise; export {}; //# sourceMappingURL=stable-audio.d.ts.map