Instructions to use HKUSTAudio/AudioX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Stable Audio Tools
How to use HKUSTAudio/AudioX 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("HKUSTAudio/AudioX") 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
Requiring Python 3.8.x in the Conda install seems to cause lots of dependency failures
#1
by braknurr - opened
DAC/Decord and a bunch of other dependencies in the stable_audio_tools subpath require at least Python 3.9x.
python -m pip install dac
ERROR: Ignored the following versions that require a different python version: 0.2.0 Requires-Python >=3.9; 0.3.0 Requires-Python >=3.9; 0.3.1 Requires-Python >=3.9; 0.3.2 Requires-Python >=3.9; 0.3.3 Requires-Python >=3.9; 0.4.0 Requires-Python >=3.9; 0.4.1 Requires-Python >=3.9; 0.4.2 Requires-Python >=3.9; 0.4.2rc1 Requires-Python >=3.9; 0.4.3 Requires-Python <3.14,>=3.9; 0.4.3rc0 Requires-Python <3.12,>=3.9
ERROR: Could not find a version that satisfies the requirement dac (from versions: none)
ERROR: No matching distribution found for dac
I've gotten around it by just setting the conda env to Py 3.9 - doesn't seem to cause any issues.
braknurr changed discussion status to closed