Views
No views yet
| Checkpoint | Task | UNet Model Size | Total Model Size | Training Data / h |
|---|---|---|---|---|
| audioldm2 | Text-to-audio | 350M | 1.1B | 1150k |
| audioldm2-large | Text-to-audio | 750M | 1.5B | 1150k |
| audioldm2-music | Text-to-music | 350M | 1.1B | 665k |
pip install --upgrade diffusers transformers accelerate1from diffusers import AudioLDM2Pipeline
2import torch
3
4repo_id = "cvssp/audioldm2"
5pipe = AudioLDM2Pipeline.from_pretrained(repo_id, torch_dtype=torch.float16)
6pipe = pipe.to("cuda")
7
8prompt = "The sound of a hammer hitting a wooden surface"
9audio = pipe(prompt, num_inference_steps=200, audio_length_in_s=10.0).audios[0]1import scipy
2
3scipy.io.wavfile.write("techno.wav", rate=16000, data=audio)1from IPython.display import Audio
2
3Audio(audio, rate=16000)num_inference_steps argument: higher steps give higher quality audio at the expense of slower inference.audio_length_in_s argument.num_waveforms_per_prompt to a value greater than 1. Automatic scoring will be performed between the generated waveforms and prompt text, and the audios ranked from best to worst accordingly.1import scipy
2import torch
3from diffusers import AudioLDM2Pipeline
4
5# load the pipeline
6repo_id = "cvssp/audioldm2"
7pipe = AudioLDM2Pipeline.from_pretrained(repo_id, torch_dtype=torch.float16)
8pipe = pipe.to("cuda")
9
10# define the prompts
11prompt = "The sound of a hammer hitting a wooden surface"
12negative_prompt = "Low quality."
13
14# set the seed
15generator = torch.Generator("cuda").manual_seed(0)
16
17# run the generation
18audio = pipe(
19 prompt,
20 negative_prompt=negative_prompt,
21 num_inference_steps=200,
22 audio_length_in_s=10.0,
23 num_waveforms_per_prompt=3,
24).audios
25
26# save the best audio sample (index 0) as a .wav file
27scipy.io.wavfile.write("techno.wav", rate=16000, data=audio[0])@article{liu2023audioldm2,
title={"AudioLDM 2: Learning Holistic Audio Generation with Self-supervised Pretraining"},
author={Haohe Liu and Qiao Tian and Yi Yuan and Xubo Liu and Xinhao Mei and Qiuqiang Kong and Yuping Wang and Wenwu Wang and Yuxuan Wang and Mark D. Plumbley},
journal={arXiv preprint arXiv:2308.05734},
year={2023}
}