Files
xsl 24c526af68 feat(assets): SA3 音效补齐 radio 11+1 与 dungeon 13源+15pan(token 走 hf-mirror 实测可用)
- 模型 17/17 文件经镜像全量缓存(gated+token,直连本机不通;sfx.md/setup.md/asset-pipeline.md 镜像结论同步更新)
- 修复迁移遗留:stable_audio_3/models/ 源码子包被 .gitignore models/ 规则误伤丢失,从上游恢复并加白名单
- radio:arg_muffled/brake_screech 等叙事件落地(接线原有 L111/L154 零改动)+ phone_ring SYN→SA3 升级;dungeon 13 源 A/B 对齐(RMS 偏差 ≤0.3dB)全量同名替换,SYN 原版备份 tools/asset_fix_backup/sa3_ab_20260902/
- 关键玩法语义达标:echo 距离档 0.83<1.43<2.18<2.98s 严格递增;one-shot 真峰值全 ≤-3dBFS(解码回读法)
- check_all_assets 8 游戏全绿(radio 254/254、dungeon 303/303);playtest radio 221/dungeon 1610 全绿
2026-09-02 19:35:38 +08:00

64 lines
3.0 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Stable Audio 3 small-sfx — 本地音效生成
## 位置
- 代码仓库: `/home/ubuntu/SoundGame/tools/stable-audio-3`
- Python 环境: `/home/ubuntu/SoundGame/tools/stable-audio-3/.venv`(uv 管理,Python 3.10)
- PyTorch: 2.7.1+cu126(CUDA 可用,RTX 3090 已验证)
- 模型缓存: `/home/ubuntu/SoundGame/models/hf`(通过 `HF_HOME` 指定)
- 环境变量: `source /home/ubuntu/SoundGame/env.d/sfx.sh`
## 首次使用:必须申请模型访问权限(gated repo)
`stabilityai/stable-audio-3-small-sfx` 是 **gated(auto 批准)** 仓库,匿名下载返回 403,必须:
1. 注册/登录 HuggingFace 账号(可用镜像 https://hf-mirror.com 浏览,但 accept 协议需在官网完成;官网打不开时可用镜像站对应的模型页 https://hf-mirror.com/stabilityai/stable-audio-3-small-sfx 登录后接受)。
2. 打开模型页 **https://huggingface.co/stabilityai/stable-audio-3-small-sfx**,点击接受 **Stable Audio Community License**(auto 模式,提交后立即通过,无需人工审核)。
3. 在 https://huggingface.co/settings/tokens 创建一个 **read** 权限的 token。
4. 把 token 写入 `/home/ubuntu/SoundGame/env.d/sfx.sh` 最后一行的 `HF_TOKEN`(去掉注释)。
注意:本机 huggingface.co 不可达,下载走 `HF_ENDPOINT=https://hf-mirror.com`(已在 sfx.sh 中设置),gated 模型带 token 经镜像下载是支持的。
(2026-09-02 实测:small-sfx 17 文件全量经镜像下载成功;模型入缓存后可加 `HF_HUB_OFFLINE=1` 离线跑 CLI。)
## 生成音效(CLI)
```bash
source /home/ubuntu/SoundGame/env.d/sfx.sh
cd /home/ubuntu/SoundGame/tools/stable-audio-3
# 3 秒冒烟测试
uv run stable-audio --model small-sfx \
-p "footsteps on gravel, slow walking" \
--duration 3 \
-o /home/ubuntu/SoundGame/tools/samples/sfx_test.wav
```
- 提示词必须是**英文**(模型只懂英文)。
- `--duration` 最长 120s;`--steps` 默认 8;small 模型峰值显存约 2.4GB(120s 时),与 TTS 共存无冲突。
- 多个提示词可批量生成:`-p "prompt1" "prompt2" --duration 3 5`。
- 其他功能:audio-to-audio(`--init-audio`)、inpainting(`--inpaint-audio/--inpaint-start/--inpaint-end`),详见 `uv run stable-audio --help`。
## Gradio UI
```bash
cd /home/ubuntu/SoundGame/tools/stable-audio-3
uv run python run_gradio.py --model small-sfx
```
## Python API
```python
from stable_audio_3 import StableAudioModel
model = StableAudioModel.from_pretrained("small-sfx")
audio = model.generate(prompt="thunder rumbling in the distance", duration=3)
```
## 提示词参考
见仓库内 `docs/guides/prompting.md`。
## 状态记录(2026-08-29)
- [x] 仓库克隆 + `uv sync --extra ui` 完成(PyPI 走阿里云镜像,torch 走官方 cu126 源)
- [x] torch CUDA 验证通过:`torch 2.7.1+cu126, cuda: True, NVIDIA GeForce RTX 3090`
- [x] CLI 可用(flash_attn 未安装的警告可忽略,仅 medium 需要)
- [ ] 模型权重下载被 gated 403 拦截 —— 待用户申请 token 后重跑上面的冒烟测试