从 Stable Audio 官方 GitHub README 翻译整理的快速上手指南。
Stable Audio 是 Stability AI 开源的音频生成模型训练与推理工具库(GitHub: Stability-AI/stable-audio-tools)。它基于 PyTorch 构建,支持 Flash Attention 和 Flex Attention 加速,使用 PyTorch Lightning 实现多 GPU/多节点训练。项目采用 uv 进行依赖管理,开发环境基于 Python 3.10。
git clone https://github.com/Stability-AI/stable-audio-tools.git
cd stable-audio-tools
uv sync
uv sync --extra train
uv sync --extra train --extra ui
pip install "stable-audio-tools[train]"
注意:建议安装 Flash Attention 以获得更好性能,可在
uv sync后参考其官方文档安装。
以 stable-audio-open-1.0 模型为例(需先在 Hugging Face 接受模型使用条款):
python3 ./run_gradio.py --pretrained-name stabilityai/stable-audio-open-1.0
| 参数 | 说明 |
|---|---|
--pretrained-name |
Hugging Face 上的模型仓库名 |
--model-config |
本地模型配置文件路径 |
--ckpt-path |
本地模型检查点路径 |
--pretransform-ckpt-path |
替换预变换模块的检查点(用于测试微调解码器) |
--share |
生成公开分享链接 |
--username / --password |
设置登录认证 |
--model-half |
使用半精度加载模型权重 |
wandb login
python3 ./train.py --dataset-config /path/to/dataset/config --model-config /path/to/model/config --name harmonai_train
训练产生的检查点包含训练包装器(含判别器、EMA 副本、优化器状态等),推理前需解包:
python3 ./unwrap_model.py --model-config /path/to/model/config --ckpt-path /path/to/wrapped/ckpt --name model_unwrap
解包后的模型可用于推理、作为其他模型的预变换模块或进行微调。
--ckpt-path 参数--pretrained-ckpt-path 参数stabilityai/stable-audio-open-1.0 等模型翻译整理自 GitHub README,原文:https://github.com/Stability-AI/stable-audio-tools