Improve model card
#1
by
nielsr
HF Staff
- opened
README.md
CHANGED
|
@@ -1,104 +1,106 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: cc-by-nc-4.0
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
conda
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
from
|
| 35 |
-
from stable_audio_tools
|
| 36 |
-
from stable_audio_tools.
|
| 37 |
-
import
|
| 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 |
```
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-4.0
|
| 3 |
+
pipeline_tag: audio-to-audio
|
| 4 |
+
library_name: stable-audio-tools
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
# AudioX
|
| 8 |
+
|
| 9 |
+
## ๐ง AudioX: Diffusion Transformer for Anything-to-Audio Generation
|
| 10 |
+
|
| 11 |
+
[TL;DR]: AudioX is a unified Diffusion Transformer model for Anything-to-Audio and Music Generation, capable of generating high-quality general audio and music, offering flexible natural language control, and seamlessly processing various modalities including text, video, image, music, and audio.
|
| 12 |
+
|
| 13 |
+
### Links
|
| 14 |
+
- **[Paper](https://arxiv.org/abs/2503.10522)**: Explore the research behind AudioX.
|
| 15 |
+
- **[Project](https://zeyuet.github.io/AudioX/)**: Visit the official project page for more information and updates.
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
## Clone the repository
|
| 19 |
+
```bash
|
| 20 |
+
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/Zeyue7/AudioX
|
| 21 |
+
cd AudioX
|
| 22 |
+
|
| 23 |
+
conda create -n AudioX python=3.8.20
|
| 24 |
+
conda activate AudioX
|
| 25 |
+
pip install git+https://github.com/ZeyueT/AudioX.git
|
| 26 |
+
conda install -c conda-forge ffmpeg libsndfile
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
## Usage
|
| 30 |
+
|
| 31 |
+
```py
|
| 32 |
+
import torch
|
| 33 |
+
import torchaudio
|
| 34 |
+
from einops import rearrange
|
| 35 |
+
from stable_audio_tools import get_pretrained_model
|
| 36 |
+
from stable_audio_tools.inference.generation import generate_diffusion_cond
|
| 37 |
+
from stable_audio_tools.data.utils import read_video, merge_video_audio
|
| 38 |
+
from stable_audio_tools.data.utils import load_and_process_audio
|
| 39 |
+
import os
|
| 40 |
+
|
| 41 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 42 |
+
|
| 43 |
+
# Download model
|
| 44 |
+
model, model_config = get_pretrained_model("Zeyue7/AudioX")
|
| 45 |
+
sample_rate = model_config["sample_rate"]
|
| 46 |
+
sample_size = model_config["sample_size"]
|
| 47 |
+
target_fps = model_config["video_fps"]
|
| 48 |
+
seconds_start = 0
|
| 49 |
+
seconds_total = 10
|
| 50 |
+
|
| 51 |
+
model = model.to(device)
|
| 52 |
+
|
| 53 |
+
# for video-to-music generation
|
| 54 |
+
video_path = "video.mp4"
|
| 55 |
+
text_prompt = "Generate music for the video"
|
| 56 |
+
audio_path = None
|
| 57 |
+
|
| 58 |
+
video_tensor = read_video(video_path, seek_time=0, duration=seconds_total, target_fps=target_fps)
|
| 59 |
+
audio_tensor = load_and_process_audio(audio_path, sample_rate, seconds_start, seconds_total)
|
| 60 |
+
|
| 61 |
+
conditioning = [{
|
| 62 |
+
"video_prompt": [video_tensor.unsqueeze(0)],
|
| 63 |
+
"text_prompt": text_prompt,
|
| 64 |
+
"audio_prompt": audio_tensor.unsqueeze(0),
|
| 65 |
+
"seconds_start": seconds_start,
|
| 66 |
+
"seconds_total": seconds_total
|
| 67 |
+
}]
|
| 68 |
+
|
| 69 |
+
# Generate stereo audio
|
| 70 |
+
output = generate_diffusion_cond(
|
| 71 |
+
model,
|
| 72 |
+
steps=250,
|
| 73 |
+
cfg_scale=7,
|
| 74 |
+
conditioning=conditioning,
|
| 75 |
+
sample_size=sample_size,
|
| 76 |
+
sigma_min=0.3,
|
| 77 |
+
sigma_max=500,
|
| 78 |
+
sampler_type="dpmpp-3m-sde",
|
| 79 |
+
device=device
|
| 80 |
+
)
|
| 81 |
+
|
| 82 |
+
# Rearrange audio batch to a single sequence
|
| 83 |
+
output = rearrange(output, "b d n -> d (b n)")
|
| 84 |
+
|
| 85 |
+
# Peak normalize, clip, convert to int16, and save to file
|
| 86 |
+
output = output.to(torch.float32).div(torch.max(torch.abs(output))).clamp(-1, 1).mul(32767).to(torch.int16).cpu()
|
| 87 |
+
torchaudio.save("output.wav", output, sample_rate)
|
| 88 |
+
|
| 89 |
+
if video_path is not None and os.path.exists(video_path):
|
| 90 |
+
merge_video_audio(video_path, "output.wav", "output.mp4", 0, seconds_total)
|
| 91 |
+
|
| 92 |
+
```
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
## Citation
|
| 97 |
+
If you find our work useful, please consider citing:
|
| 98 |
+
|
| 99 |
+
```
|
| 100 |
+
@article{tian2025audiox,
|
| 101 |
+
title={AudioX: Diffusion Transformer for Anything-to-Audio Generation},
|
| 102 |
+
author={Tian, Zeyue and Jin, Yizhu and Liu, Zhaoyang and Yuan, Ruibin and Tan, Xu and Chen, Qifeng and Xue, Wei and Guo, Yike},
|
| 103 |
+
journal={arXiv preprint arXiv:2503.10522},
|
| 104 |
+
year={2025}
|
| 105 |
+
}
|
| 106 |
```
|