Views
No views yet
Note: This repository contains experimental checkpoints optimised for acceleration on specific hardware. For standard checkpoints, please use Stable Audio 3 Medium 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("medium")
4audio = model.generate(
5 prompt=(
6 "House music that encapsulates the feeling of being at a festival "
7 "in the sunny weather with all your friends 124 BPM"
8 ),
9 duration=180
10)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-medium")
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": (
22 "A dream-like Synthpop instrumental that would accompany "
23 "a dream-sequence in a surrealist movie 120 BPM"
24 ),
25 "seconds_total": 380
26}]
27
28# Generate stereo audio
29output = generate_diffusion_cond_inpaint(
30 model,
31 steps=8,
32 cfg_scale=1.0,
33 conditioning=conditioning,
34 sample_size=sample_size,
35 sampler_type="pingpong",
36 device=device
37)
38
39# Rearrange audio batch to a single sequence
40output = rearrange(output, "b d n -> d (b n)")
41
42# Peak normalize, clip, convert to int16, and save to file
43output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
44torchaudio.save("output.wav", output, sample_rate)Stable Audio 3 is a latent diffusion model based on a transformer architecture.