Instructions to use cudabenchmarktest/stable-audio-open-1.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Stable Audio Tools
How to use cudabenchmarktest/stable-audio-open-1.0 with Stable Audio Tools:
import torch import torchaudio from einops import rearrange from stable_audio_tools import get_pretrained_model from stable_audio_tools.inference.generation import generate_diffusion_cond device = "cuda" if torch.cuda.is_available() else "cpu" # Download model model, model_config = get_pretrained_model("cudabenchmarktest/stable-audio-open-1.0") sample_rate = model_config["sample_rate"] sample_size = model_config["sample_size"] model = model.to(device) # Set up text and timing conditioning conditioning = [{ "prompt": "128 BPM tech house drum loop", }] # Generate stereo audio output = generate_diffusion_cond( model, conditioning=conditioning, sample_size=sample_size, device=device ) # Rearrange audio batch to a single sequence output = rearrange(output, "b d n -> d (b n)") # Peak normalize, clip, convert to int16, and save to file output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu() torchaudio.save("output.wav", output, sample_rate) - Notebooks
- Google Colab
- Kaggle
File size: 3,608 Bytes
35537b3 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 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 | {
"model_type": "autoencoder",
"sample_size": 65536,
"sample_rate": 44100,
"audio_channels": 2,
"model": {
"encoder": {
"type": "oobleck",
"config": {
"in_channels": 2,
"channels": 128,
"c_mults": [1, 2, 4, 8, 16],
"strides": [2, 4, 4, 8, 8],
"latent_dim": 128,
"use_snake": true
}
},
"decoder": {
"type": "oobleck",
"config": {
"out_channels": 2,
"channels": 128,
"c_mults": [1, 2, 4, 8, 16],
"strides": [2, 4, 4, 8, 8],
"latent_dim": 64,
"use_snake": true,
"final_tanh": false
}
},
"bottleneck": {
"type": "vae"
},
"latent_dim": 64,
"downsampling_ratio": 2048,
"io_channels": 2
},
"training": {
"learning_rate": 5e-5,
"warmup_steps": 0,
"use_ema": true,
"optimizer_configs": {
"autoencoder": {
"optimizer": {
"type": "AdamW",
"config": {
"betas": [0.8, 0.99],
"lr": 1.5e-4,
"weight_decay": 1e-3
}
},
"scheduler": {
"type": "InverseLR",
"config": {
"inv_gamma": 100000,
"power": 0.5,
"warmup": 0.999
}
}
},
"discriminator": {
"optimizer": {
"type": "AdamW",
"config": {
"betas": [0.8, 0.99],
"lr": 3e-4,
"weight_decay": 1e-3
}
},
"scheduler": {
"type": "InverseLR",
"config": {
"inv_gamma": 100000,
"power": 0.5,
"warmup": 0.999
}
}
}
},
"loss_configs": {
"discriminator": {
"type": "encodec",
"config": {
"filters": 32,
"n_ffts": [2048, 1024, 512, 256, 128],
"hop_lengths": [512, 256, 128, 64, 32],
"win_lengths": [2048, 1024, 512, 256, 128]
},
"weights": {
"adversarial": 0.1,
"feature_matching": 25.0
}
},
"spectral": {
"type": "mrstft",
"config": {
"fft_sizes": [2048, 1024, 512, 256, 128, 64, 32],
"hop_sizes": [512, 256, 128, 64, 32, 16, 8],
"win_lengths": [2048, 1024, 512, 256, 128, 64, 32],
"perceptual_weighting": true
},
"weights": {
"mrstft": 1.0
}
},
"time": {
"type": "l1",
"weights": {
"l1": 0.0
}
},
"bottleneck": {
"type": "kl",
"weights": {
"kl": 1e-5
}
}
},
"demo": {
"demo_every": 2000
}
}
} |