@memef1f1y/dsh-plugin-tts 0.6.5 → 0.6.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.yml +51 -51
- package/.github/ISSUE_TEMPLATE/config.yml +2 -2
- package/.github/ISSUE_TEMPLATE/feature_request.yml +28 -28
- package/.github/pull_request_template.md +7 -7
- package/.github/workflows/contrib-triage.yml +66 -66
- package/.github/workflows/linked-issue.yml +21 -21
- package/.github/workflows/publish.yml +63 -0
- package/.github/workflows/stale.yml +30 -30
- package/.github/workflows/test.yml +33 -33
- package/.github/workflows/welcome.yml +22 -22
- package/ANALYSIS.md +205 -205
- package/PR-REVIEW.md +74 -74
- package/README.md +335 -335
- package/TODO.md +34 -34
- package/docs/HOST-CONTRACT.md +36 -36
- package/docs/RVC-GUIDE.md +390 -390
- package/docs/USER-GUIDE.md +389 -389
- package/docs/acceptance-checklist.md +147 -147
- package/docs/adaptive-chunked-playback.md +194 -194
- package/docs/macos-test-prompt.md +230 -230
- package/docs/windows-gpu-verify-prompt.md +151 -151
- package/lib/client.js +7164 -7164
- package/lib/index.mjs +3374 -3374
- package/package.json +51 -51
- package/rvc-server.py +564 -564
- package/tests/README.md +45 -45
- package/tests/client-load.mjs +406 -406
- package/tests/e2e-compact-index.mjs +86 -86
- package/tests/e2e-index-ab.mjs +138 -138
- package/tests/e2e-real-rvc.mjs +122 -122
- package/tests/i18n-keys.mjs +82 -82
- package/tests/package-runtime-patch.mjs +88 -88
- package/tests/rvc-server-live.mjs +230 -230
- package/tests/smoke.mjs +1284 -1284
- package/tools/gen-ui-preview.mjs +174 -174
- package/tools/mac-verify.sh +158 -158
- package/tools/package-runtime.py +214 -214
|
@@ -1,230 +1,230 @@
|
|
|
1
|
-
# macOS 跨平台实测 Prompt(粘贴给 Mac 上的 LLM)
|
|
2
|
-
|
|
3
|
-
> 用法:把本文全文(从「# 任务」到文末)粘贴给 Mac 上的 LLM(或放入其工作目录让它读取)。
|
|
4
|
-
> 它是自包含的:Mac 上的 LLM 看不到 Windows 这边的对话,一切信息都在下面。
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
# 任务
|
|
9
|
-
|
|
10
|
-
你是运行在一台 **macOS 电脑** 上的 AI 助手。你的任务是**在真实 macOS 环境里验证一个开源语音插件的 RVC 变声服务能否跨平台运行**,并如实报告结果(包括失败)。这个插件叫 `dsh-plugin-tts`,Windows 上已完整验证通过(RTX 5070 GPU),但 **macOS 从未实测**——本次就是要补上这个测试,发现任何问题都算有价值的产出。
|
|
11
|
-
|
|
12
|
-
# 背景:被测对象是什么
|
|
13
|
-
|
|
14
|
-
`dsh-plugin-tts` 是一个文本转语音插件,其中「自定义音色(RVC)」模式的工作方式是:
|
|
15
|
-
|
|
16
|
-
1. 一个本地 HTTP 服务 `rvc-server.py` 包装 RVC 的推理核心(一个叫 `infer/` 的代码目录);
|
|
17
|
-
2. 插件把文字先用微软 Edge TTS 读成原声,再把原声音频 POST 给这个服务做音色转换;
|
|
18
|
-
3. 服务把转换后的音频返回给插件播放。
|
|
19
|
-
|
|
20
|
-
`rvc-server.py` 的 HTTP 协议(JSON + base64,无其他依赖):
|
|
21
|
-
|
|
22
|
-
- `GET /health` — 服务状态、设备、已加载模型
|
|
23
|
-
- `GET /files?kind=pth|index` — 扫描本机模型/索引文件
|
|
24
|
-
- `POST /load {"model": "<绝对路径>", "index": "<绝对路径或空>"}` — 加载音色模型
|
|
25
|
-
- `POST /convert {"audio_base64": "<wav 的 base64>", "params": {...}}` — 转换(`f0_method` 默认 `rmvpe`)
|
|
26
|
-
- `POST /compact-index {"index": "<.index 路径>", "target_vectors": 2000}` — 把大索引压缩成小索引
|
|
27
|
-
|
|
28
|
-
macOS 上设备会自动选 **CPU**(`device=cpu, is_half=false`),转换比 Windows GPU 慢是**正常现象**,不算失败。
|
|
29
|
-
|
|
30
|
-
# 本机已验证的环境组合(Windows,务必尽量复刻)
|
|
31
|
-
|
|
32
|
-
| 组件 | 版本 |
|
|
33
|
-
|---|---|
|
|
34
|
-
| Python | 3.9.13 |
|
|
35
|
-
| torch / torchaudio | 2.0.0 / 2.0.1 |
|
|
36
|
-
| fairseq | 0.12.2(PyPI 官方版) |
|
|
37
|
-
| numpy / numba / llvmlite | 1.23.5 / 0.56.4 / 0.39.1 |
|
|
38
|
-
| librosa / scipy | 0.9.1 / 1.9.3 |
|
|
39
|
-
| soundfile / pyworld / resampy | 0.11.0+ / 0.3.2 / 0.4.2 |
|
|
40
|
-
| fastapi / uvicorn | 0.88.0 / 0.20.0 |
|
|
41
|
-
| faiss | faiss-cpu |
|
|
42
|
-
|
|
43
|
-
> 这组版本已被证实与 `rvc-server.py` + 这套 `infer/` 代码兼容。macOS 上**优先按这个表装**;个别包在 macOS 装不上时,见「常见坑」。
|
|
44
|
-
|
|
45
|
-
# 前置条件检查
|
|
46
|
-
|
|
47
|
-
1. macOS 12 或更新(Apple Silicon 或 Intel 均可,推荐 ≥16GB 内存、≥10GB 空闲磁盘);
|
|
48
|
-
2. 已安装:`git`、`ffmpeg`(`brew install ffmpeg`)、Xcode Command Line Tools(`xcode-select --install`);
|
|
49
|
-
3. Python 3.9:推荐用 pyenv(`brew install pyenv && pyenv install 3.9.18 && pyenv local 3.9.18`)。系统自带的 python3 版本若 ≥3.10 也可以先试,但依赖装不上时必须回到 3.9。
|
|
50
|
-
|
|
51
|
-
# 步骤 1:准备 RVC 推理核心 `infer/`
|
|
52
|
-
|
|
53
|
-
`rvc-server.py` 要求旁边有一个 `infer/` 目录(RVC 的推理核心,纯 Python 代码,约 0.7MB)。二选一:
|
|
54
|
-
|
|
55
|
-
- **方案 A(推荐,与已验证代码完全一致)**:用户会从 Windows 机器把 `infer/` 目录和 `requirements.txt` 拷给你(会放在某个约定路径,比如 `~/rvc-transfer/infer/`)。如果没找到,先问用户。
|
|
56
|
-
- **方案 B(拿不到 Windows 文件时)**:
|
|
57
|
-
```bash
|
|
58
|
-
git clone --depth 1 https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git rvc-src
|
|
59
|
-
cp -r rvc-src/infer ~/rvc-work/infer
|
|
60
|
-
cp rvc-src/requirements.txt ~/rvc-work/requirements.txt
|
|
61
|
-
```
|
|
62
|
-
注意:**新版 RVC 仓库(当前 HEAD)的 `infer/` 已经整体重构,不能直接用**——布局从
|
|
63
|
-
`infer/modules/vc/ + infer/lib/infer_pack/` 变成了 `infer/vc/ + infer/module/`,
|
|
64
|
-
hubert 也改成了 HuggingFace Transformers 格式,与 `rvc-server.py` 期望的旧版结构
|
|
65
|
-
(`from infer.modules.vc.modules import VC` 等)完全不兼容,连 `infer/modules` 目录都不存在。
|
|
66
|
-
实测请改用**旧版 tag**(与其锁定依赖匹配):
|
|
67
|
-
```bash
|
|
68
|
-
git clone --depth 1 https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git rvc-src
|
|
69
|
-
cd rvc-src && git fetch --depth 1 origin tag 2.2.231006
|
|
70
|
-
git archive 2.2.231006 infer/ | tar -x -C ../rvc-work/
|
|
71
|
-
git show 2.2.231006:requirements.txt > ../rvc-work/requirements.txt
|
|
72
|
-
```
|
|
73
|
-
若坚持用新布局,`rvc-server.py` 会直接 `ModuleNotFoundError`(没有 `infer/modules`)。
|
|
74
|
-
|
|
75
|
-
另外无论哪种 infer:**手装依赖时,除锁定版本清单外还需** `av`、`praat-parselmouth`、
|
|
76
|
-
`torchcrepe`;`faiss-cpu` 用 `==1.7.3`(最新 1.13 要求 numpy≥1.25);装 `fairseq==0.12.2`
|
|
77
|
-
前把 pip 降到 **<24.1**;保持 `setuptools<81`(否则缺 `pkg_resources`)。
|
|
78
|
-
|
|
79
|
-
# 步骤 2:搭工作目录和模型资产
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
mkdir -p ~/rvc-work/assets/hubert ~/rvc-work/assets/rmvpe ~/rvc-work/assets/weights
|
|
83
|
-
cd ~/rvc-work
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
下载 RVC 必需的两个推理模型(共约 360MB;HuggingFace 在国内可能慢,用 `hf-mirror.com` 镜像):
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
# hubert 特征提取模型(约 181MB)——路径必须与 infer/ 代码引用一致(本套代码是 assets/hubert/hubert_base.pt)
|
|
90
|
-
curl -L -o assets/hubert/hubert_base.pt \
|
|
91
|
-
https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt
|
|
92
|
-
# 若上面失败/太慢:
|
|
93
|
-
# https://hf-mirror.com/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt
|
|
94
|
-
|
|
95
|
-
# rmvpe 音高提取模型(约 173MB)
|
|
96
|
-
curl -L -o assets/rmvpe/rmvpe.pt \
|
|
97
|
-
https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt
|
|
98
|
-
# 镜像:https://hf-mirror.com/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
下载测试音色包(公开仓库 `1624318455/rvc-for-tts`,作者自己训练的音色,许可见仓库 manifest):
|
|
102
|
-
|
|
103
|
-
```bash
|
|
104
|
-
curl -L -o assets/weights/model.pth \
|
|
105
|
-
https://raw.githubusercontent.com/1624318455/rvc-for-tts/main/packs/guanguanV1/model.pth # 52.5MB
|
|
106
|
-
curl -L -o assets/weights/guanguanV1.index \
|
|
107
|
-
https://raw.githubusercontent.com/1624318455/rvc-for-tts/main/packs/guanguanV1/guanguanV1.index # 32MB(可选)
|
|
108
|
-
# raw.githubusercontent 慢/失败时可用 ghproxy 类镜像,或请用户从 Windows 机器拷
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
# 步骤 3:建 Python 环境(锁定已验证版本)
|
|
112
|
-
|
|
113
|
-
```bash
|
|
114
|
-
cd ~/rvc-work
|
|
115
|
-
python3.9 -m venv venv # 或 pyenv 的 3.9
|
|
116
|
-
source venv/bin/activate
|
|
117
|
-
pip install -U pip setuptools wheel Cython
|
|
118
|
-
|
|
119
|
-
pip install \
|
|
120
|
-
torch==2.0.0 torchaudio==2.0.1 \
|
|
121
|
-
numpy==1.23.5 numba==0.56.4 llvmlite==0.39.1 \
|
|
122
|
-
librosa==0.9.1 scipy==1.9.3 \
|
|
123
|
-
soundfile>=0.12.1 pyworld==0.3.2 resampy==0.4.2 \
|
|
124
|
-
fastapi==0.88.0 uvicorn==0.20.0 \
|
|
125
|
-
fairseq==0.12.2 faiss-cpu
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
装完立即验证关键依赖能 import(fairseq 是 hubert 加载的依赖,最容易出问题):
|
|
129
|
-
|
|
130
|
-
```bash
|
|
131
|
-
python -c "import torch, fairseq, faiss, numpy, librosa; from fairseq import checkpoint_utils; print('deps ok', torch.__version__, numpy.__version__)"
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
- 若 `fairseq` 装不上(源码编译失败):先 `pip install --no-build-isolation fairseq==0.12.2`;还不行就试 RVC 官方用的 fork:`pip install "fairseq @ git+https://github.com/One-sixth/fairseq.git"`;都失败就**记录完整报错并继续**(这本身就是测试要收集的信息)。
|
|
135
|
-
- 若报 `np.float` / `np.int` 之类 numpy 兼容错误:`pip install "numpy<1.24"` 强制降回。
|
|
136
|
-
- 若新版 macOS 上 torch 2.0.0 装不上:改 `torch==2.6.0 torchaudio==2.6.0`(`rvc-server.py` 已内置 torch≥2.6 的 `weights_only=False` 补丁,Windows 侧 torch 2.7 验证过)。
|
|
137
|
-
|
|
138
|
-
# 步骤 4:获取被测代码并启动服务
|
|
139
|
-
|
|
140
|
-
```bash
|
|
141
|
-
git clone https://github.com/1624318455/dsh-plugin-tts.git ~/dsh-plugin-tts
|
|
142
|
-
cp ~/dsh-plugin-tts/rvc-server.py ~/rvc-work/
|
|
143
|
-
cp ~/dsh-plugin-tts/tools/mac-verify.sh ~/rvc-work/
|
|
144
|
-
|
|
145
|
-
cd ~/rvc-work
|
|
146
|
-
nohup venv/bin/python rvc-server.py --port 4892 > server.log 2>&1 &
|
|
147
|
-
sleep 8
|
|
148
|
-
tail -20 server.log
|
|
149
|
-
```
|
|
150
|
-
|
|
151
|
-
**成功的样子**:日志出现 `dsh-plugin-tts RVC server: http://127.0.0.1:4892 (device=cpu, half=False)`。
|
|
152
|
-
(不要传 `--device cuda`——macOS 没有 CUDA,`--device auto` 默认就是 cpu。)
|
|
153
|
-
启动失败就贴完整报错,先排查再继续。
|
|
154
|
-
|
|
155
|
-
# 步骤 5:端到端验证(核心)
|
|
156
|
-
|
|
157
|
-
跑验证脚本(它会依次测 `/health` → `/files` → `/load` → `/convert` → 输出文件 → `/compact-index`):
|
|
158
|
-
|
|
159
|
-
```bash
|
|
160
|
-
cd ~/rvc-work
|
|
161
|
-
PY=~/rvc-work/venv/bin/python bash mac-verify.sh \
|
|
162
|
-
~/rvc-work/assets/weights/model.pth \
|
|
163
|
-
~/rvc-work/assets/weights/guanguanV1.index
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
预期:
|
|
167
|
-
|
|
168
|
-
- `/health`:`ok:true`、`device:"cpu"`、`cuda_available:false`、`index_cache:true`;
|
|
169
|
-
- `/files`:列出下载的 model.pth;
|
|
170
|
-
- `/load`:`ok:true`,返回模型绝对路径(首次会打印 `Loaded model ... (v2, f0=1, ...)`);
|
|
171
|
-
- `/convert`:首次要加载 hubert+rmvpe(约 30~90 秒,之后快),返回 `sample_rate` 与转换后 wav;输出文件是 RIFF,时长≈输入(约 3 秒);
|
|
172
|
-
- `/compact-index`:返回 `reduction_pct`(几十 %,因为源索引本身不大)。
|
|
173
|
-
|
|
174
|
-
脚本会自己判断 PASS/FAIL。**如果脚本某步失败,不要只报"失败"**——手工复现那一步(curl / python),把 HTTP 状态码、响应体、服务端日志(server.log 尾部)都收集进报告。
|
|
175
|
-
|
|
176
|
-
# 步骤 6(可选):打包脚本 `package-runtime.py` 的 darwin 分支
|
|
177
|
-
|
|
178
|
-
**仅当这台 Mac 上已有一个 RVC WebUI 安装(目录里含 `runtime/` 和 `infer/`)时执行**;没有就跳过并在报告里注明「无 RVC 安装,跳过」。
|
|
179
|
-
|
|
180
|
-
```bash
|
|
181
|
-
python3 ~/dsh-plugin-tts/tools/package-runtime.py \
|
|
182
|
-
--rvc-dir <RVC安装目录> --out ~/rvc-portable-mac --platform darwin
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
验证产物:
|
|
186
|
-
|
|
187
|
-
1. 结构正确:`~/rvc-portable-mac/runtime/bin/python` 存在、`infer/`、`assets/hubert/`、`assets/rmvpe/`、`rvc-server.py`、`start-rvc-server.sh`(且 `ls -l` 有 x 权限);
|
|
188
|
-
2. 用产物启动并重测一遍核心链路:
|
|
189
|
-
```bash
|
|
190
|
-
~/rvc-portable-mac/start-rvc-server.sh & # 或 ~/rvc-portable-mac/runtime/bin/python ~/rvc-portable-mac/rvc-server.py --port 4893
|
|
191
|
-
PY=~/rvc-portable-mac/runtime/bin/python bash mac-verify.sh \
|
|
192
|
-
~/rvc-portable-mac/assets/weights/model.pth "" 127.0.0.1:4893
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
# 必须汇报的内容(最终报告格式)
|
|
196
|
-
|
|
197
|
-
1. **环境**:macOS 版本、芯片(`uname -m`)、Python 版本、torch 版本、numpy 版本;
|
|
198
|
-
2. **步骤 1-4 的产物**:用了方案 A 还是 B、各文件是否就位(ls 大小);
|
|
199
|
-
3. **步骤 5 结果**:mac-verify.sh 每步 PASS/FAIL + 关键输出(/health 的 JSON、/convert 的耗时与 sample_rate、out.wav 时长);
|
|
200
|
-
4. **耗时数据**:`/convert` 的 wall 耗时与「几倍实时」(CPU 慢正常,记录下来即可);
|
|
201
|
-
5. **任何报错**:完整堆栈/响应体/服务端日志,不要截断;
|
|
202
|
-
6. **步骤 6**:执行了/跳过了;执行了就给产物结构 + 重测结果;
|
|
203
|
-
7. **结论**:macOS 上能否端到端使用;哪些地方需要作者修复或改文档。
|
|
204
|
-
|
|
205
|
-
**重要**:如实汇报。失败、装不上的包、跑不通的步骤都是本次测试的正当产出——宁可报失败,也不要为了让报告好看而省略或掩盖。
|
|
206
|
-
|
|
207
|
-
# 常见坑速查
|
|
208
|
-
|
|
209
|
-
- **HuggingFace 下载慢/超时** → 换 `https://hf-mirror.com/...` 前缀;
|
|
210
|
-
- **GitHub raw 下载慢** → ghproxy 类镜像或让用户拷文件;
|
|
211
|
-
- **fairseq 装不上** → 先 `pip install "pip<24.1"` 降 pip(实测根因是 omegaconf 的
|
|
212
|
-
`PyYAML>=5.1.*` 元数据被新 pip 拒绝,`--no-build-isolation` 无效);再不行才试
|
|
213
|
-
One-sixth fork(见步骤 3);
|
|
214
|
-
- **numpy 2.x 报错** → `pip install "numpy<1.24"`;
|
|
215
|
-
- **缺 `pkg_resources` / librosa 导入失败** → `pip install "setuptools<81"`(新 setuptools 移除了它);
|
|
216
|
-
- **缺 `av` / `parselmouth` / `torchcrepe`** → 旧版 infer 的隐式依赖,`pip install av praat-parselmouth torchcrepe`;
|
|
217
|
-
- **faiss-cpu 装了 1.13 与 numpy 1.23.5 冲突** → `pip install "faiss-cpu==1.7.3"`;
|
|
218
|
-
- **/convert 报 `mode must be 'r', 'w', or None, got: rb`** → PyAV≥10 拒绝 `"rb"/"wb"`
|
|
219
|
-
(macOS 无法装老 PyAV 绕开):手动把 `infer/lib/audio.py` 的
|
|
220
|
-
`av.open(i,"rb")→av.open(i,"r")`、`av.open(o,"wb",...)→av.open(o,"w",...)`;
|
|
221
|
-
用 `package-runtime.py --platform darwin` 打包会自动打此补丁;
|
|
222
|
-
- **mac-verify.sh 第 5 步误报 "not a RIFF file"(exit 1)** → 脚本自身 bug:macOS 的
|
|
223
|
-
`od` 字节间双空格使 `grep "52 49 46 46"` 匹配不到。用新版(已改去空格比 hex)或
|
|
224
|
-
确认 `file out.wav` 确实是 "RIFF ..." 即视为通过;
|
|
225
|
-
- **方案 B 的 infer 目录结构与 rvc-server.py 不匹配** → 当前 HEAD 已重构,用旧 tag
|
|
226
|
-
`2.2.231006`(见步骤 1);
|
|
227
|
-
- **端口被占用** → 换 `--port 4893`,verify 脚本第三个参数跟着改;
|
|
228
|
-
- **/convert 报 `no model loaded`** → 先 /load 成功再 /convert;
|
|
229
|
-
- **/convert 报 `audio decode failed`** → 确认系统 ffmpeg 可用(`ffmpeg -version`);
|
|
230
|
-
- **/convert 超时/极慢** → CPU 推理正常慢,等;若 15 分钟无响应再查 server.log。
|
|
1
|
+
# macOS 跨平台实测 Prompt(粘贴给 Mac 上的 LLM)
|
|
2
|
+
|
|
3
|
+
> 用法:把本文全文(从「# 任务」到文末)粘贴给 Mac 上的 LLM(或放入其工作目录让它读取)。
|
|
4
|
+
> 它是自包含的:Mac 上的 LLM 看不到 Windows 这边的对话,一切信息都在下面。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# 任务
|
|
9
|
+
|
|
10
|
+
你是运行在一台 **macOS 电脑** 上的 AI 助手。你的任务是**在真实 macOS 环境里验证一个开源语音插件的 RVC 变声服务能否跨平台运行**,并如实报告结果(包括失败)。这个插件叫 `dsh-plugin-tts`,Windows 上已完整验证通过(RTX 5070 GPU),但 **macOS 从未实测**——本次就是要补上这个测试,发现任何问题都算有价值的产出。
|
|
11
|
+
|
|
12
|
+
# 背景:被测对象是什么
|
|
13
|
+
|
|
14
|
+
`dsh-plugin-tts` 是一个文本转语音插件,其中「自定义音色(RVC)」模式的工作方式是:
|
|
15
|
+
|
|
16
|
+
1. 一个本地 HTTP 服务 `rvc-server.py` 包装 RVC 的推理核心(一个叫 `infer/` 的代码目录);
|
|
17
|
+
2. 插件把文字先用微软 Edge TTS 读成原声,再把原声音频 POST 给这个服务做音色转换;
|
|
18
|
+
3. 服务把转换后的音频返回给插件播放。
|
|
19
|
+
|
|
20
|
+
`rvc-server.py` 的 HTTP 协议(JSON + base64,无其他依赖):
|
|
21
|
+
|
|
22
|
+
- `GET /health` — 服务状态、设备、已加载模型
|
|
23
|
+
- `GET /files?kind=pth|index` — 扫描本机模型/索引文件
|
|
24
|
+
- `POST /load {"model": "<绝对路径>", "index": "<绝对路径或空>"}` — 加载音色模型
|
|
25
|
+
- `POST /convert {"audio_base64": "<wav 的 base64>", "params": {...}}` — 转换(`f0_method` 默认 `rmvpe`)
|
|
26
|
+
- `POST /compact-index {"index": "<.index 路径>", "target_vectors": 2000}` — 把大索引压缩成小索引
|
|
27
|
+
|
|
28
|
+
macOS 上设备会自动选 **CPU**(`device=cpu, is_half=false`),转换比 Windows GPU 慢是**正常现象**,不算失败。
|
|
29
|
+
|
|
30
|
+
# 本机已验证的环境组合(Windows,务必尽量复刻)
|
|
31
|
+
|
|
32
|
+
| 组件 | 版本 |
|
|
33
|
+
|---|---|
|
|
34
|
+
| Python | 3.9.13 |
|
|
35
|
+
| torch / torchaudio | 2.0.0 / 2.0.1 |
|
|
36
|
+
| fairseq | 0.12.2(PyPI 官方版) |
|
|
37
|
+
| numpy / numba / llvmlite | 1.23.5 / 0.56.4 / 0.39.1 |
|
|
38
|
+
| librosa / scipy | 0.9.1 / 1.9.3 |
|
|
39
|
+
| soundfile / pyworld / resampy | 0.11.0+ / 0.3.2 / 0.4.2 |
|
|
40
|
+
| fastapi / uvicorn | 0.88.0 / 0.20.0 |
|
|
41
|
+
| faiss | faiss-cpu |
|
|
42
|
+
|
|
43
|
+
> 这组版本已被证实与 `rvc-server.py` + 这套 `infer/` 代码兼容。macOS 上**优先按这个表装**;个别包在 macOS 装不上时,见「常见坑」。
|
|
44
|
+
|
|
45
|
+
# 前置条件检查
|
|
46
|
+
|
|
47
|
+
1. macOS 12 或更新(Apple Silicon 或 Intel 均可,推荐 ≥16GB 内存、≥10GB 空闲磁盘);
|
|
48
|
+
2. 已安装:`git`、`ffmpeg`(`brew install ffmpeg`)、Xcode Command Line Tools(`xcode-select --install`);
|
|
49
|
+
3. Python 3.9:推荐用 pyenv(`brew install pyenv && pyenv install 3.9.18 && pyenv local 3.9.18`)。系统自带的 python3 版本若 ≥3.10 也可以先试,但依赖装不上时必须回到 3.9。
|
|
50
|
+
|
|
51
|
+
# 步骤 1:准备 RVC 推理核心 `infer/`
|
|
52
|
+
|
|
53
|
+
`rvc-server.py` 要求旁边有一个 `infer/` 目录(RVC 的推理核心,纯 Python 代码,约 0.7MB)。二选一:
|
|
54
|
+
|
|
55
|
+
- **方案 A(推荐,与已验证代码完全一致)**:用户会从 Windows 机器把 `infer/` 目录和 `requirements.txt` 拷给你(会放在某个约定路径,比如 `~/rvc-transfer/infer/`)。如果没找到,先问用户。
|
|
56
|
+
- **方案 B(拿不到 Windows 文件时)**:
|
|
57
|
+
```bash
|
|
58
|
+
git clone --depth 1 https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git rvc-src
|
|
59
|
+
cp -r rvc-src/infer ~/rvc-work/infer
|
|
60
|
+
cp rvc-src/requirements.txt ~/rvc-work/requirements.txt
|
|
61
|
+
```
|
|
62
|
+
注意:**新版 RVC 仓库(当前 HEAD)的 `infer/` 已经整体重构,不能直接用**——布局从
|
|
63
|
+
`infer/modules/vc/ + infer/lib/infer_pack/` 变成了 `infer/vc/ + infer/module/`,
|
|
64
|
+
hubert 也改成了 HuggingFace Transformers 格式,与 `rvc-server.py` 期望的旧版结构
|
|
65
|
+
(`from infer.modules.vc.modules import VC` 等)完全不兼容,连 `infer/modules` 目录都不存在。
|
|
66
|
+
实测请改用**旧版 tag**(与其锁定依赖匹配):
|
|
67
|
+
```bash
|
|
68
|
+
git clone --depth 1 https://github.com/RVC-Project/Retrieval-based-Voice-Conversion-WebUI.git rvc-src
|
|
69
|
+
cd rvc-src && git fetch --depth 1 origin tag 2.2.231006
|
|
70
|
+
git archive 2.2.231006 infer/ | tar -x -C ../rvc-work/
|
|
71
|
+
git show 2.2.231006:requirements.txt > ../rvc-work/requirements.txt
|
|
72
|
+
```
|
|
73
|
+
若坚持用新布局,`rvc-server.py` 会直接 `ModuleNotFoundError`(没有 `infer/modules`)。
|
|
74
|
+
|
|
75
|
+
另外无论哪种 infer:**手装依赖时,除锁定版本清单外还需** `av`、`praat-parselmouth`、
|
|
76
|
+
`torchcrepe`;`faiss-cpu` 用 `==1.7.3`(最新 1.13 要求 numpy≥1.25);装 `fairseq==0.12.2`
|
|
77
|
+
前把 pip 降到 **<24.1**;保持 `setuptools<81`(否则缺 `pkg_resources`)。
|
|
78
|
+
|
|
79
|
+
# 步骤 2:搭工作目录和模型资产
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
mkdir -p ~/rvc-work/assets/hubert ~/rvc-work/assets/rmvpe ~/rvc-work/assets/weights
|
|
83
|
+
cd ~/rvc-work
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
下载 RVC 必需的两个推理模型(共约 360MB;HuggingFace 在国内可能慢,用 `hf-mirror.com` 镜像):
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
# hubert 特征提取模型(约 181MB)——路径必须与 infer/ 代码引用一致(本套代码是 assets/hubert/hubert_base.pt)
|
|
90
|
+
curl -L -o assets/hubert/hubert_base.pt \
|
|
91
|
+
https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt
|
|
92
|
+
# 若上面失败/太慢:
|
|
93
|
+
# https://hf-mirror.com/lj1995/VoiceConversionWebUI/resolve/main/hubert_base.pt
|
|
94
|
+
|
|
95
|
+
# rmvpe 音高提取模型(约 173MB)
|
|
96
|
+
curl -L -o assets/rmvpe/rmvpe.pt \
|
|
97
|
+
https://huggingface.co/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt
|
|
98
|
+
# 镜像:https://hf-mirror.com/lj1995/VoiceConversionWebUI/resolve/main/rmvpe.pt
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
下载测试音色包(公开仓库 `1624318455/rvc-for-tts`,作者自己训练的音色,许可见仓库 manifest):
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
curl -L -o assets/weights/model.pth \
|
|
105
|
+
https://raw.githubusercontent.com/1624318455/rvc-for-tts/main/packs/guanguanV1/model.pth # 52.5MB
|
|
106
|
+
curl -L -o assets/weights/guanguanV1.index \
|
|
107
|
+
https://raw.githubusercontent.com/1624318455/rvc-for-tts/main/packs/guanguanV1/guanguanV1.index # 32MB(可选)
|
|
108
|
+
# raw.githubusercontent 慢/失败时可用 ghproxy 类镜像,或请用户从 Windows 机器拷
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
# 步骤 3:建 Python 环境(锁定已验证版本)
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
cd ~/rvc-work
|
|
115
|
+
python3.9 -m venv venv # 或 pyenv 的 3.9
|
|
116
|
+
source venv/bin/activate
|
|
117
|
+
pip install -U pip setuptools wheel Cython
|
|
118
|
+
|
|
119
|
+
pip install \
|
|
120
|
+
torch==2.0.0 torchaudio==2.0.1 \
|
|
121
|
+
numpy==1.23.5 numba==0.56.4 llvmlite==0.39.1 \
|
|
122
|
+
librosa==0.9.1 scipy==1.9.3 \
|
|
123
|
+
soundfile>=0.12.1 pyworld==0.3.2 resampy==0.4.2 \
|
|
124
|
+
fastapi==0.88.0 uvicorn==0.20.0 \
|
|
125
|
+
fairseq==0.12.2 faiss-cpu
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
装完立即验证关键依赖能 import(fairseq 是 hubert 加载的依赖,最容易出问题):
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
python -c "import torch, fairseq, faiss, numpy, librosa; from fairseq import checkpoint_utils; print('deps ok', torch.__version__, numpy.__version__)"
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
- 若 `fairseq` 装不上(源码编译失败):先 `pip install --no-build-isolation fairseq==0.12.2`;还不行就试 RVC 官方用的 fork:`pip install "fairseq @ git+https://github.com/One-sixth/fairseq.git"`;都失败就**记录完整报错并继续**(这本身就是测试要收集的信息)。
|
|
135
|
+
- 若报 `np.float` / `np.int` 之类 numpy 兼容错误:`pip install "numpy<1.24"` 强制降回。
|
|
136
|
+
- 若新版 macOS 上 torch 2.0.0 装不上:改 `torch==2.6.0 torchaudio==2.6.0`(`rvc-server.py` 已内置 torch≥2.6 的 `weights_only=False` 补丁,Windows 侧 torch 2.7 验证过)。
|
|
137
|
+
|
|
138
|
+
# 步骤 4:获取被测代码并启动服务
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
git clone https://github.com/1624318455/dsh-plugin-tts.git ~/dsh-plugin-tts
|
|
142
|
+
cp ~/dsh-plugin-tts/rvc-server.py ~/rvc-work/
|
|
143
|
+
cp ~/dsh-plugin-tts/tools/mac-verify.sh ~/rvc-work/
|
|
144
|
+
|
|
145
|
+
cd ~/rvc-work
|
|
146
|
+
nohup venv/bin/python rvc-server.py --port 4892 > server.log 2>&1 &
|
|
147
|
+
sleep 8
|
|
148
|
+
tail -20 server.log
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**成功的样子**:日志出现 `dsh-plugin-tts RVC server: http://127.0.0.1:4892 (device=cpu, half=False)`。
|
|
152
|
+
(不要传 `--device cuda`——macOS 没有 CUDA,`--device auto` 默认就是 cpu。)
|
|
153
|
+
启动失败就贴完整报错,先排查再继续。
|
|
154
|
+
|
|
155
|
+
# 步骤 5:端到端验证(核心)
|
|
156
|
+
|
|
157
|
+
跑验证脚本(它会依次测 `/health` → `/files` → `/load` → `/convert` → 输出文件 → `/compact-index`):
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
cd ~/rvc-work
|
|
161
|
+
PY=~/rvc-work/venv/bin/python bash mac-verify.sh \
|
|
162
|
+
~/rvc-work/assets/weights/model.pth \
|
|
163
|
+
~/rvc-work/assets/weights/guanguanV1.index
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
预期:
|
|
167
|
+
|
|
168
|
+
- `/health`:`ok:true`、`device:"cpu"`、`cuda_available:false`、`index_cache:true`;
|
|
169
|
+
- `/files`:列出下载的 model.pth;
|
|
170
|
+
- `/load`:`ok:true`,返回模型绝对路径(首次会打印 `Loaded model ... (v2, f0=1, ...)`);
|
|
171
|
+
- `/convert`:首次要加载 hubert+rmvpe(约 30~90 秒,之后快),返回 `sample_rate` 与转换后 wav;输出文件是 RIFF,时长≈输入(约 3 秒);
|
|
172
|
+
- `/compact-index`:返回 `reduction_pct`(几十 %,因为源索引本身不大)。
|
|
173
|
+
|
|
174
|
+
脚本会自己判断 PASS/FAIL。**如果脚本某步失败,不要只报"失败"**——手工复现那一步(curl / python),把 HTTP 状态码、响应体、服务端日志(server.log 尾部)都收集进报告。
|
|
175
|
+
|
|
176
|
+
# 步骤 6(可选):打包脚本 `package-runtime.py` 的 darwin 分支
|
|
177
|
+
|
|
178
|
+
**仅当这台 Mac 上已有一个 RVC WebUI 安装(目录里含 `runtime/` 和 `infer/`)时执行**;没有就跳过并在报告里注明「无 RVC 安装,跳过」。
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
python3 ~/dsh-plugin-tts/tools/package-runtime.py \
|
|
182
|
+
--rvc-dir <RVC安装目录> --out ~/rvc-portable-mac --platform darwin
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
验证产物:
|
|
186
|
+
|
|
187
|
+
1. 结构正确:`~/rvc-portable-mac/runtime/bin/python` 存在、`infer/`、`assets/hubert/`、`assets/rmvpe/`、`rvc-server.py`、`start-rvc-server.sh`(且 `ls -l` 有 x 权限);
|
|
188
|
+
2. 用产物启动并重测一遍核心链路:
|
|
189
|
+
```bash
|
|
190
|
+
~/rvc-portable-mac/start-rvc-server.sh & # 或 ~/rvc-portable-mac/runtime/bin/python ~/rvc-portable-mac/rvc-server.py --port 4893
|
|
191
|
+
PY=~/rvc-portable-mac/runtime/bin/python bash mac-verify.sh \
|
|
192
|
+
~/rvc-portable-mac/assets/weights/model.pth "" 127.0.0.1:4893
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
# 必须汇报的内容(最终报告格式)
|
|
196
|
+
|
|
197
|
+
1. **环境**:macOS 版本、芯片(`uname -m`)、Python 版本、torch 版本、numpy 版本;
|
|
198
|
+
2. **步骤 1-4 的产物**:用了方案 A 还是 B、各文件是否就位(ls 大小);
|
|
199
|
+
3. **步骤 5 结果**:mac-verify.sh 每步 PASS/FAIL + 关键输出(/health 的 JSON、/convert 的耗时与 sample_rate、out.wav 时长);
|
|
200
|
+
4. **耗时数据**:`/convert` 的 wall 耗时与「几倍实时」(CPU 慢正常,记录下来即可);
|
|
201
|
+
5. **任何报错**:完整堆栈/响应体/服务端日志,不要截断;
|
|
202
|
+
6. **步骤 6**:执行了/跳过了;执行了就给产物结构 + 重测结果;
|
|
203
|
+
7. **结论**:macOS 上能否端到端使用;哪些地方需要作者修复或改文档。
|
|
204
|
+
|
|
205
|
+
**重要**:如实汇报。失败、装不上的包、跑不通的步骤都是本次测试的正当产出——宁可报失败,也不要为了让报告好看而省略或掩盖。
|
|
206
|
+
|
|
207
|
+
# 常见坑速查
|
|
208
|
+
|
|
209
|
+
- **HuggingFace 下载慢/超时** → 换 `https://hf-mirror.com/...` 前缀;
|
|
210
|
+
- **GitHub raw 下载慢** → ghproxy 类镜像或让用户拷文件;
|
|
211
|
+
- **fairseq 装不上** → 先 `pip install "pip<24.1"` 降 pip(实测根因是 omegaconf 的
|
|
212
|
+
`PyYAML>=5.1.*` 元数据被新 pip 拒绝,`--no-build-isolation` 无效);再不行才试
|
|
213
|
+
One-sixth fork(见步骤 3);
|
|
214
|
+
- **numpy 2.x 报错** → `pip install "numpy<1.24"`;
|
|
215
|
+
- **缺 `pkg_resources` / librosa 导入失败** → `pip install "setuptools<81"`(新 setuptools 移除了它);
|
|
216
|
+
- **缺 `av` / `parselmouth` / `torchcrepe`** → 旧版 infer 的隐式依赖,`pip install av praat-parselmouth torchcrepe`;
|
|
217
|
+
- **faiss-cpu 装了 1.13 与 numpy 1.23.5 冲突** → `pip install "faiss-cpu==1.7.3"`;
|
|
218
|
+
- **/convert 报 `mode must be 'r', 'w', or None, got: rb`** → PyAV≥10 拒绝 `"rb"/"wb"`
|
|
219
|
+
(macOS 无法装老 PyAV 绕开):手动把 `infer/lib/audio.py` 的
|
|
220
|
+
`av.open(i,"rb")→av.open(i,"r")`、`av.open(o,"wb",...)→av.open(o,"w",...)`;
|
|
221
|
+
用 `package-runtime.py --platform darwin` 打包会自动打此补丁;
|
|
222
|
+
- **mac-verify.sh 第 5 步误报 "not a RIFF file"(exit 1)** → 脚本自身 bug:macOS 的
|
|
223
|
+
`od` 字节间双空格使 `grep "52 49 46 46"` 匹配不到。用新版(已改去空格比 hex)或
|
|
224
|
+
确认 `file out.wav` 确实是 "RIFF ..." 即视为通过;
|
|
225
|
+
- **方案 B 的 infer 目录结构与 rvc-server.py 不匹配** → 当前 HEAD 已重构,用旧 tag
|
|
226
|
+
`2.2.231006`(见步骤 1);
|
|
227
|
+
- **端口被占用** → 换 `--port 4893`,verify 脚本第三个参数跟着改;
|
|
228
|
+
- **/convert 报 `no model loaded`** → 先 /load 成功再 /convert;
|
|
229
|
+
- **/convert 报 `audio decode failed`** → 确认系统 ffmpeg 可用(`ffmpeg -version`);
|
|
230
|
+
- **/convert 超时/极慢** → CPU 推理正常慢,等;若 15 分钟无响应再查 server.log。
|