Instructions to use stabilityai/stable-codec-speech-16k with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Stable Audio Tools
How to use stabilityai/stable-codec-speech-16k 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("stabilityai/stable-codec-speech-16k") 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
Will the causal version also be released?
#1
by stp99 - opened
In the paper, the authors state that the model is non-causal. However, they also mention training a causal version.
Will the causal variant be released as well?
The causal results in the paper were added in response to a request by the reviewers. We don’t currently have plans to release the causal model, as the design is not really optimised for the use-cases where causality is needed (like streaming).
If you want to explore a causal version yourself, it’s relatively easy to fine tune the released model with modified sliding windows and causal convolutions.
Thanks!
stp99 changed discussion status to closed