Views
No views yet
Note: This is the base (pre-trained) model intended for fine-tuning. If you are looking to generate audio directly, please use Stable Audio 3 Small SFX instead.
Stable Audio 3 is a family of fast latent diffusion models (small, medium, large) for variable length audio generation and editing. Since our models can generate several minutes of audio,
variable-length generations are key to avoid the cost of producing full-length generations for short
sounds. We also support inpainting, enabling targeted audio editing and the continuation of short
recordings. Our latent diffusion models operate on top of a novel semantic-acoustic autoencoder that
projects audio into a compact latent space, enabling efficient diffusion-based generation while preserving audio fidelity and encouraging semantic structure in the latent. Finally, we run adversarial
post-training to both accelerate inference and improve generation quality, reducing the number of inference steps while improving fidelity and prompt adherence. Stable Audio 3 models are trained on
licensed and Creative Commons data to generate music and sounds in less than a 2s on an H200 GPU
and less than a few seconds on a MacBook Pro M4. We release the weights of small and medium,
that can run on consumer-grade hardware, together with their training and inference pipeline.stable-audio-3 inference and fine-tuning librarystable-audio-tools research librarystable-audio-31from stable_audio_3 import StableAudioModel
2
3model = StableAudioModel.from_pretrained("small-sfx-base")
4audio = model.generate(
5 prompt="chugging train coming into station with horn",
6 duration=7,
7 steps=50,
8 cfg_scale=7.0
9)stable-audio-tools1import torch
2import torchaudio
3from einops import rearrange
4from stable_audio_tools import get_pretrained_model
5from stable_audio_tools.inference.generation import generate_diffusion_cond_inpaint
6
7device = "cuda" if torch.cuda.is_available() else "cpu"
8if device == "cuda":
9 model_half = True
10
11# Download model
12model, model_config = get_pretrained_model("stabilityai/stable-audio-3-small-sfx-base")
13sample_rate = model_config["sample_rate"]
14sample_size = model_config["sample_size"]
15
16model = model.to(device)
17if model_half:
18 model = model.to(torch.float16)
19# Set up text and timing conditioning
20conditioning = [{
21 "prompt": "chugging train coming into station with horn",
22 "seconds_total": 7
23}]
24
25# Generate stereo audio
26output = generate_diffusion_cond_inpaint(
27 model,
28 steps=50,
29 cfg_scale=7.0,
30 conditioning=conditioning,
31 sample_size=sample_size,
32 sampler_type="euler",
33 device=device
34)
35
36# Rearrange audio batch to a single sequence
37output = rearrange(output, "b d n -> d (b n)")
38
39# Peak normalize, clip, convert to int16, and save to file
40output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
41torchaudio.save("output.wav", output, sample_rate)Stable Audio 3 is a latent diffusion model based on a transformer architecture.