2026-02-03 18:11:50 +08:00
|
|
|
# Text-To-Audio
|
|
|
|
|
|
|
|
|
|
Source <https://github.com/vllm-project/vllm-omni/tree/main/examples/offline_inference/text_to_audio>.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The `stabilityai/stable-audio-open-1.0` pipeline generates audio from text prompts.
|
|
|
|
|
|
|
|
|
|
## Prerequisites
|
|
|
|
|
|
|
|
|
|
If you use a gated model (e.g., `stabilityai/stable-audio-open-1.0`), ensure you have access:
|
|
|
|
|
|
|
|
|
|
1. **Accept Model License**: Visit the model page on Hugging Face (e.g., [stabilityai/stable-audio-open-1.0]) and accept the user agreement.
|
|
|
|
|
2. **Authenticate**: Log in to Hugging Face locally to access the gated model.
|
|
|
|
|
```bash
|
|
|
|
|
huggingface-cli login
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Local CLI Usage
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
python text_to_audio.py \
|
|
|
|
|
--model stabilityai/stable-audio-open-1.0 \
|
|
|
|
|
--prompt "The sound of a hammer hitting a wooden surface" \
|
2026-02-11 17:17:48 +08:00
|
|
|
--negative-prompt "Low quality" \
|
2026-02-03 18:11:50 +08:00
|
|
|
--seed 42 \
|
2026-02-11 17:17:48 +08:00
|
|
|
--guidance-scale 7.0 \
|
|
|
|
|
--audio-length 10.0 \
|
|
|
|
|
--num-inference-steps 100 \
|
2026-02-03 18:11:50 +08:00
|
|
|
--output stable_audio_output.wav
|
|
|
|
|
```
|
|
|
|
|
|
2026-04-21 18:13:20 +08:00
|
|
|
To reduce per-GPU memory for multi-GPU inference, launch with HSDP:
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
python text_to_audio.py \
|
|
|
|
|
--model stabilityai/stable-audio-open-1.0 \
|
|
|
|
|
--prompt "The sound of a hammer hitting a wooden surface" \
|
|
|
|
|
--negative-prompt "Low quality" \
|
|
|
|
|
--seed 42 \
|
|
|
|
|
--guidance-scale 7.0 \
|
|
|
|
|
--audio-length 10.0 \
|
|
|
|
|
--num-inference-steps 100 \
|
|
|
|
|
--use-hsdp \
|
|
|
|
|
--hsdp-shard-size 2 \
|
|
|
|
|
--output stable_audio_output.wav
|
|
|
|
|
```
|
|
|
|
|
|
2026-02-03 18:11:50 +08:00
|
|
|
Key arguments:
|
|
|
|
|
|
|
|
|
|
- `--prompt`: text description (string).
|
2026-02-11 17:17:48 +08:00
|
|
|
- `--negative-prompt`: negative prompt for classifier-free guidance.
|
2026-02-03 18:11:50 +08:00
|
|
|
- `--seed`: integer seed for deterministic generation.
|
2026-02-11 17:17:48 +08:00
|
|
|
- `--guidance-scale`: classifier-free guidance scale.
|
|
|
|
|
- `--audio-length`: audio duration in seconds.
|
|
|
|
|
- `--num-inference-steps`: diffusion sampling steps.(more steps = higher quality, slower).
|
2026-04-21 18:13:20 +08:00
|
|
|
- `--use-hsdp`: enable HSDP weight sharding for the Stable Audio DiT.
|
|
|
|
|
- `--hsdp-shard-size`: number of GPUs used for HSDP sharding.
|
|
|
|
|
- `--hsdp-replicate-size`: number of HSDP replica groups.
|
2026-02-03 18:11:50 +08:00
|
|
|
- `--output`: path to save the generated WAV file.
|
2026-05-05 22:49:57 +08:00
|
|
|
- `--enable-cpu-offload`: enabling model-wise offloading to save gpu memory
|
|
|
|
|
- `--enable-layerwise-offload`: enabling layerwise offloading to save gpu memory
|
2026-02-03 18:11:50 +08:00
|
|
|
|
|
|
|
|
## Example materials
|
|
|
|
|
|
|
|
|
|
??? abstract "text_to_audio.py"
|
|
|
|
|
``````py
|
|
|
|
|
--8<-- "examples/offline_inference/text_to_audio/text_to_audio.py"
|
|
|
|
|
``````
|