cortico-world-fish-sing 0.2.0 → 0.3.1
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/CHANGELOG.md +96 -76
- package/dist/{webui-39b0a58f.js → webui-e202b726.js} +37 -2
- package/dist/webui.js +37 -2
- package/package.json +2 -2
- package/src/world.ts +19 -5
- package/tools/publish.mjs +99 -0
- package/worker/trainer.py +59 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,76 +1,96 @@
|
|
|
1
|
-
# 更新日志
|
|
2
|
-
|
|
3
|
-
格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循语义化。
|
|
4
|
-
|
|
5
|
-
## [0.
|
|
6
|
-
|
|
7
|
-
###
|
|
8
|
-
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
###
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
-
|
|
52
|
-
|
|
53
|
-
## [0.1.
|
|
54
|
-
|
|
55
|
-
### 修复
|
|
56
|
-
-
|
|
57
|
-
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
1
|
+
# 更新日志
|
|
2
|
+
|
|
3
|
+
格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循语义化。
|
|
4
|
+
|
|
5
|
+
## [0.3.1] - 2026-11-01
|
|
6
|
+
|
|
7
|
+
### 修复
|
|
8
|
+
- 0.3.0 的训练页面板产物漏了「低音增强」勾选框(加控件后忘跑 bundle-webui,发布的还是旧哈希产物)。重新打包为 webui-e202b726.js。
|
|
9
|
+
|
|
10
|
+
## [0.3.0] - 2026-11-01
|
|
11
|
+
|
|
12
|
+
### 新增
|
|
13
|
+
- **低音增强(治"低音不像"的根本手段)**:训练时把每个切片用 ffmpeg 合成 -2/-4 半音的低音数据一起训练,模型由此学到低音区的音色映射,不再只靠采样加权硬顶。训练页勾选框「低音增强」(默认开)。
|
|
14
|
+
- 副本命名 `aug<shift>_<原名>`,与原切片一起铺进 F0/特征两层;
|
|
15
|
+
- 采样权重按「源 + 副本」总份数摊薄(3x 低音源 + 2 副本 → 各 1x),避免与加权叠加成 9x 过采样;
|
|
16
|
+
- 实测:415Hz 切片的 -2/-4 副本基频 370/329Hz,精确命中理论值。
|
|
17
|
+
- 代价:F0/特征提取时间约 ×3(数据量 ×3)。
|
|
18
|
+
- **发版脚本 `tools/publish.mjs`**:CHANGELOG 缺条目硬性拦截 → npm publish → 轮询 tarball 可用(覆盖 2~6 分钟 CDN 延迟)→ 收尾提醒。`--check` 只查不发。
|
|
19
|
+
|
|
20
|
+
## [0.2.1] - 2026-11-01
|
|
21
|
+
|
|
22
|
+
### 新增
|
|
23
|
+
- **选模对比进面板 + 手动入口**:训练页新增勾选框「训练完生成选模对比」(默认勾)与「生成选模对比」按钮(对实验名里的实验手动跑一次,前提是还有中间档)。此前该功能只有 config.json 字段且纯自动触发,界面上完全不可见。
|
|
24
|
+
|
|
25
|
+
## [0.2.0] - 2026-11-01
|
|
26
|
+
|
|
27
|
+
### 新增
|
|
28
|
+
- **选模对比试听(自动化)**:训练完成后自动用一句训练切片(目标音色清唱),对 final + 最后两个中间档各换声一遍——输入完全一致,听出来的差异全是存档本身的差别。片段进作品库;配了 `notify.qqTarget` 的话同时逐条发 QQ,桌宠也会说一声。
|
|
29
|
+
- 模型热切换:worker 不重启,临时把 `weight_root` 指到存档所在目录后 `get_vc`,对比完恢复原模型。
|
|
30
|
+
- 配置 `train.abTest`(默认开)可关。
|
|
31
|
+
|
|
32
|
+
### 修复
|
|
33
|
+
- 引擎初始状态的 `model_path` 补上绝对路径——之前选模对比结束后的「恢复原模型」会按相对路径找不到文件。
|
|
34
|
+
|
|
35
|
+
## [0.1.9] - 2026-11-01
|
|
36
|
+
|
|
37
|
+
### 新增
|
|
38
|
+
- **worker 看门狗**:worker 意外退出时自动拉起(5s → 60s 指数退避;稳定跑满 5 分钟清零计数;连崩 5 次放弃并明确告警)。Coo 正常退出仍会收掉进程。
|
|
39
|
+
- **tmp 清理竞态保护**:调用端超时/失败后不再立刻删工作目录(worker 里的任务可能还在写),改为等任务落终态再删(最多等 10 分钟);另加 24 小时兜底清扫,覆盖「清理也失败」的情况。
|
|
40
|
+
|
|
41
|
+
## [0.1.8] - 2026-11-01
|
|
42
|
+
|
|
43
|
+
### 修复
|
|
44
|
+
- **「重装运行时」报 9009 后运行时半卸载**(用户反馈):安装用的系统 Python 之前恒写死 `python` 且不做验证——PATH 上没有 Python 的机器直接 9009,而 venv 是「先删旧的再建新的」,删完建失败就只剩残骸,之后所有子进程全是 `WinError 2`。现在:
|
|
45
|
+
- 安装前**逐个候选真跑一次**验证版本(PATH 的 python/py、`%LOCALAPPDATA%\Programs\Python`、`C:\Python3x`),挑出真正可用的 3.9~3.13;一个都没有时报人话错误,指引用户先装 Python;
|
|
46
|
+
- venv 创建改**原子替换**:先建 `venv.new`,成功才让旧 venv 让位,失败保留旧的——安装失败不再把能用的运行时弄坏。
|
|
47
|
+
|
|
48
|
+
## [0.1.7] - 2026-11-01
|
|
49
|
+
|
|
50
|
+
### 修复
|
|
51
|
+
- **唱歌中途超时(连续两次实战)**:音域分析在 worker 进程内跑,pyin 长时间持有 Python GIL,HTTP 线程无法应答进度轮询(单次请求 10 秒超时),调用端断开后任务连带失败。现在分析挪到**子进程**执行(约 3 秒),HTTP 全程畅通。
|
|
52
|
+
|
|
53
|
+
## [0.1.6] - 2026-11-01
|
|
54
|
+
|
|
55
|
+
### 修复
|
|
56
|
+
- **变调推荐改保守策略**:之前按低音端精确对齐,给女声源也推 +6,实测移调的音色损失比低音区稍微出格更伤。现在:源曲与模型音域差 ≤8 半音一律不移调;>8(男声原调区间)才移,上限 +6(负向 -3)。
|
|
57
|
+
- **音域分析限中段 90 秒**:之前对整首歌全量跑基音分析(5 分钟的歌约 40 秒),会把唱歌调用顶超时。现在只分析中段 90 秒,零点几秒完成。
|
|
58
|
+
- `_f0_stats` 接受字符串路径;推荐逻辑 else 分支漏赋值的低级错误。
|
|
59
|
+
|
|
60
|
+
## [0.1.5] - 2026-11-01
|
|
61
|
+
|
|
62
|
+
### 修复
|
|
63
|
+
- `pitch` 不传时默认走 `'auto'`,不再静默回落 0——之前"自动推荐"要显式传参才生效,成了摆设。
|
|
64
|
+
- 作品库记录实际使用的半音数(而非 'auto' 字样)。
|
|
65
|
+
- 配置 `voice.pitch` 默认改 `'auto'`;控制台该字段支持填数字(固定移调)或 `'auto'`。
|
|
66
|
+
|
|
67
|
+
## [0.1.4] - 2026-11-01
|
|
68
|
+
|
|
69
|
+
### 新增
|
|
70
|
+
- **变调推荐**:`pitch` 支持 `'auto'`。worker 分离出源曲人声后自动对比源曲音域与模型音域(来自训练数据,缓存在 `logs/<实验>/range.json`),唱完的返回带推荐理由。
|
|
71
|
+
- **完成通知**:训练完成/中断时主动告知。渠道可选桌宠(`pushEvent`,她会自己接话)或 QQ(OneBot 文本);QQ 失败自动退桌宠。配置在控制台「完成通知」组。
|
|
72
|
+
|
|
73
|
+
## [0.1.3] - 2026-11-01
|
|
74
|
+
|
|
75
|
+
### 修复
|
|
76
|
+
- worker 引擎的 `RVC_ROOT` 默认值不再写死 `D:\AI\rvc`:探测链为 环境变量 → 工作目录上级的 `runtime/rvc` → 旧开发目录(存在才用)。手动起 worker 忘传环境变量时不再直接崩。
|
|
77
|
+
- `FFMPEG` 默认值加 `PATH` 探测兜底。
|
|
78
|
+
|
|
79
|
+
## [0.1.2] - 2026-10-30
|
|
80
|
+
|
|
81
|
+
### 新增
|
|
82
|
+
- 首次公开发布到 npm(此前只能手动复制安装)。
|
|
83
|
+
- 控制台「安装与运行时」:一键下载权重(909 MB)+ 装运行时(约 2.5 GB),自托管在数据目录内。
|
|
84
|
+
- 训练面板:音域加权的采样训练、孤儿训练自动发现(重启 Coo 后面板能找回还在跑的训练)、停止按钮可用、中间档清理。
|
|
85
|
+
|
|
86
|
+
### 修复
|
|
87
|
+
- 训练超时改为"无进展才判卡住"(此前 15 分钟绝对超时会误杀长训练)。
|
|
88
|
+
- Coo 退出不再打断进行中的训练。
|
|
89
|
+
|
|
90
|
+
## [0.1.1] - 2026-10-30
|
|
91
|
+
|
|
92
|
+
被 npm 的暂存机制占用,从未真正上线(发布时若遇到 `E409`,升版本号即可)。
|
|
93
|
+
|
|
94
|
+
## [0.1.0 及以前]
|
|
95
|
+
|
|
96
|
+
内部版本,手动安装。
|
|
@@ -1199,7 +1199,19 @@ function mountTrain(ctx) {
|
|
|
1199
1199
|
const pruneAfterLbl = el('label', 'fs-meta', '训练完自动清理中间档');
|
|
1200
1200
|
pruneAfterLbl.prepend(pruneAfterChk);
|
|
1201
1201
|
pruneAfterLbl.title = '按下面「每 N 轮留一个」保留,其余删掉。不勾就只是提醒你手动清。';
|
|
1202
|
-
|
|
1202
|
+
const abChk = el('input', 'fs-ck');
|
|
1203
|
+
abChk.type = 'checkbox';
|
|
1204
|
+
abChk.checked = true;
|
|
1205
|
+
const abLbl = el('label', 'fs-meta', '训练完生成选模对比');
|
|
1206
|
+
abLbl.prepend(abChk);
|
|
1207
|
+
abLbl.title = '用同一句训练切片,final 和最后两个中间档各唱一遍,进作品库对比听';
|
|
1208
|
+
const lowChk = el('input', 'fs-ck');
|
|
1209
|
+
lowChk.type = 'checkbox';
|
|
1210
|
+
lowChk.checked = true;
|
|
1211
|
+
const lowLbl = el('label', 'fs-meta', '低音增强');
|
|
1212
|
+
lowLbl.prepend(lowChk);
|
|
1213
|
+
lowLbl.title = '把每个切片合成 -2/-4 半音的低音数据一起训练,治"低音不像"。F0/特征提取时间约 ×3';
|
|
1214
|
+
chkRow.append(resumeLbl, rebuildLbl, pruneAfterLbl, abLbl, lowLbl, el('span', 'fs-grow'), startT, stopT);
|
|
1203
1215
|
|
|
1204
1216
|
const tProg = el('div', 'fs-prog');
|
|
1205
1217
|
const tFill = el('i');
|
|
@@ -1219,8 +1231,10 @@ function mountTrain(ctx) {
|
|
|
1219
1231
|
keepIn.style.width = '64px';
|
|
1220
1232
|
const pruneBtn = el('button', 'fs-btn', '清理中间档');
|
|
1221
1233
|
pruneBtn.title = '只删 assets/weights/<exp>_eN_sX.pth 这种导出的小模型;完整存档、索引、最终模型都不动';
|
|
1234
|
+
const abBtn = el('button', 'fs-btn', '生成选模对比');
|
|
1235
|
+
abBtn.title = '用当前实验的存档(final + 最后两个中间档)各唱同一句训练切片,生成对比试听进作品库';
|
|
1222
1236
|
ckptBar.append(el('span', 'fs-meta', '中间档:'), ckptMeta, el('span', 'fs-meta', '每'),
|
|
1223
|
-
keepIn, el('span', 'fs-meta', '轮留一个'), el('span', 'fs-grow'), pruneBtn);
|
|
1237
|
+
keepIn, el('span', 'fs-meta', '轮留一个'), el('span', 'fs-grow'), abBtn, pruneBtn);
|
|
1224
1238
|
trainBox.append(tTitle, tForm, chkRow, tProg, tMsg, losses, lossAxis, tModels, ckptBar);
|
|
1225
1239
|
|
|
1226
1240
|
let trainExp = '';
|
|
@@ -1236,6 +1250,25 @@ function mountTrain(ctx) {
|
|
|
1236
1250
|
} catch { /* 忽略 */ }
|
|
1237
1251
|
};
|
|
1238
1252
|
|
|
1253
|
+
abBtn.addEventListener('click', async () => {
|
|
1254
|
+
const exp = String(expIn.value || '').trim() || trainExp;
|
|
1255
|
+
if (!exp) {
|
|
1256
|
+
tMsg.textContent = '先填实验名(或跑一次训练)再生成选模对比';
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
abBtn.disabled = true;
|
|
1260
|
+
abBtn.textContent = '生成中…';
|
|
1261
|
+
try {
|
|
1262
|
+
const r = await ctx.invoke('trainAbTest', [{ exp }]);
|
|
1263
|
+
tMsg.textContent = (r && r.text) || `选模对比已生成(${exp})`;
|
|
1264
|
+
} catch (e) {
|
|
1265
|
+
tMsg.textContent = `选模对比失败:${(e && e.message) || e}`;
|
|
1266
|
+
} finally {
|
|
1267
|
+
abBtn.disabled = false;
|
|
1268
|
+
abBtn.textContent = '生成选模对比';
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
|
|
1239
1272
|
pruneBtn.addEventListener('click', async () => {
|
|
1240
1273
|
if (!trainExp) return;
|
|
1241
1274
|
const step = Math.max(1, Number(keepIn.value) || 50);
|
|
@@ -1408,6 +1441,8 @@ function mountTrain(ctx) {
|
|
|
1408
1441
|
resume: resumeChk.checked,
|
|
1409
1442
|
rebuild: rebuildChk.checked,
|
|
1410
1443
|
pruneAfter: pruneAfterChk.checked,
|
|
1444
|
+
abTest: abChk.checked,
|
|
1445
|
+
augment: lowChk.checked,
|
|
1411
1446
|
keepEvery: Math.max(1, Number(keepIn.value) || 50),
|
|
1412
1447
|
}]);
|
|
1413
1448
|
if (r && r.exp) {
|
package/dist/webui.js
CHANGED
|
@@ -1199,7 +1199,19 @@ function mountTrain(ctx) {
|
|
|
1199
1199
|
const pruneAfterLbl = el('label', 'fs-meta', '训练完自动清理中间档');
|
|
1200
1200
|
pruneAfterLbl.prepend(pruneAfterChk);
|
|
1201
1201
|
pruneAfterLbl.title = '按下面「每 N 轮留一个」保留,其余删掉。不勾就只是提醒你手动清。';
|
|
1202
|
-
|
|
1202
|
+
const abChk = el('input', 'fs-ck');
|
|
1203
|
+
abChk.type = 'checkbox';
|
|
1204
|
+
abChk.checked = true;
|
|
1205
|
+
const abLbl = el('label', 'fs-meta', '训练完生成选模对比');
|
|
1206
|
+
abLbl.prepend(abChk);
|
|
1207
|
+
abLbl.title = '用同一句训练切片,final 和最后两个中间档各唱一遍,进作品库对比听';
|
|
1208
|
+
const lowChk = el('input', 'fs-ck');
|
|
1209
|
+
lowChk.type = 'checkbox';
|
|
1210
|
+
lowChk.checked = true;
|
|
1211
|
+
const lowLbl = el('label', 'fs-meta', '低音增强');
|
|
1212
|
+
lowLbl.prepend(lowChk);
|
|
1213
|
+
lowLbl.title = '把每个切片合成 -2/-4 半音的低音数据一起训练,治"低音不像"。F0/特征提取时间约 ×3';
|
|
1214
|
+
chkRow.append(resumeLbl, rebuildLbl, pruneAfterLbl, abLbl, lowLbl, el('span', 'fs-grow'), startT, stopT);
|
|
1203
1215
|
|
|
1204
1216
|
const tProg = el('div', 'fs-prog');
|
|
1205
1217
|
const tFill = el('i');
|
|
@@ -1219,8 +1231,10 @@ function mountTrain(ctx) {
|
|
|
1219
1231
|
keepIn.style.width = '64px';
|
|
1220
1232
|
const pruneBtn = el('button', 'fs-btn', '清理中间档');
|
|
1221
1233
|
pruneBtn.title = '只删 assets/weights/<exp>_eN_sX.pth 这种导出的小模型;完整存档、索引、最终模型都不动';
|
|
1234
|
+
const abBtn = el('button', 'fs-btn', '生成选模对比');
|
|
1235
|
+
abBtn.title = '用当前实验的存档(final + 最后两个中间档)各唱同一句训练切片,生成对比试听进作品库';
|
|
1222
1236
|
ckptBar.append(el('span', 'fs-meta', '中间档:'), ckptMeta, el('span', 'fs-meta', '每'),
|
|
1223
|
-
keepIn, el('span', 'fs-meta', '轮留一个'), el('span', 'fs-grow'), pruneBtn);
|
|
1237
|
+
keepIn, el('span', 'fs-meta', '轮留一个'), el('span', 'fs-grow'), abBtn, pruneBtn);
|
|
1224
1238
|
trainBox.append(tTitle, tForm, chkRow, tProg, tMsg, losses, lossAxis, tModels, ckptBar);
|
|
1225
1239
|
|
|
1226
1240
|
let trainExp = '';
|
|
@@ -1236,6 +1250,25 @@ function mountTrain(ctx) {
|
|
|
1236
1250
|
} catch { /* 忽略 */ }
|
|
1237
1251
|
};
|
|
1238
1252
|
|
|
1253
|
+
abBtn.addEventListener('click', async () => {
|
|
1254
|
+
const exp = String(expIn.value || '').trim() || trainExp;
|
|
1255
|
+
if (!exp) {
|
|
1256
|
+
tMsg.textContent = '先填实验名(或跑一次训练)再生成选模对比';
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
abBtn.disabled = true;
|
|
1260
|
+
abBtn.textContent = '生成中…';
|
|
1261
|
+
try {
|
|
1262
|
+
const r = await ctx.invoke('trainAbTest', [{ exp }]);
|
|
1263
|
+
tMsg.textContent = (r && r.text) || `选模对比已生成(${exp})`;
|
|
1264
|
+
} catch (e) {
|
|
1265
|
+
tMsg.textContent = `选模对比失败:${(e && e.message) || e}`;
|
|
1266
|
+
} finally {
|
|
1267
|
+
abBtn.disabled = false;
|
|
1268
|
+
abBtn.textContent = '生成选模对比';
|
|
1269
|
+
}
|
|
1270
|
+
});
|
|
1271
|
+
|
|
1239
1272
|
pruneBtn.addEventListener('click', async () => {
|
|
1240
1273
|
if (!trainExp) return;
|
|
1241
1274
|
const step = Math.max(1, Number(keepIn.value) || 50);
|
|
@@ -1408,6 +1441,8 @@ function mountTrain(ctx) {
|
|
|
1408
1441
|
resume: resumeChk.checked,
|
|
1409
1442
|
rebuild: rebuildChk.checked,
|
|
1410
1443
|
pruneAfter: pruneAfterChk.checked,
|
|
1444
|
+
abTest: abChk.checked,
|
|
1445
|
+
augment: lowChk.checked,
|
|
1411
1446
|
keepEvery: Math.max(1, Number(keepIn.value) || 50),
|
|
1412
1447
|
}]);
|
|
1413
1448
|
if (r && r.exp) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cortico-world-fish-sing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "让她真的开口唱:B 站点歌或本地文件 → 分离 → 换声 → 混音,本机出声或发 QQ 语音条",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"local"
|
|
37
37
|
],
|
|
38
38
|
"describe": "describe.json",
|
|
39
|
-
"webUiClient": "dist/webui-
|
|
39
|
+
"webUiClient": "dist/webui-e202b726.js"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"doctor": "node tools/doctor.mjs"
|
package/src/world.ts
CHANGED
|
@@ -315,8 +315,8 @@ export class FishSingWorld implements World {
|
|
|
315
315
|
* 的差别——比拿着不同版本整首唱一遍再凭记忆比要靠谱。
|
|
316
316
|
* 片段进作品库;配了 notify.qqTarget 就同时发 QQ。
|
|
317
317
|
*/
|
|
318
|
-
private async runAbTest(exp: string): Promise<
|
|
319
|
-
if (this.opts.cfg.train?.abTest === false) return;
|
|
318
|
+
private async runAbTest(exp: string, enabled?: boolean): Promise<string> {
|
|
319
|
+
if (enabled === false || this.opts.cfg.train?.abTest === false) return '';
|
|
320
320
|
const weights = join(this.routes.rvcRoot, 'assets', 'weights');
|
|
321
321
|
const logDir = join(this.routes.rvcRoot, 'logs', exp);
|
|
322
322
|
const indexOf = (dir: string): string => {
|
|
@@ -343,7 +343,7 @@ export class FishSingWorld implements World {
|
|
|
343
343
|
}
|
|
344
344
|
if (variants.length < 2) {
|
|
345
345
|
this.host?.log.info(`[fish-sing] ${exp} 只有一个可用存档(中间档可能被清理了),跳过选模对比`);
|
|
346
|
-
return;
|
|
346
|
+
return '';
|
|
347
347
|
}
|
|
348
348
|
const gtDir = join(logDir, '0_gt_wavs');
|
|
349
349
|
let test = '';
|
|
@@ -356,7 +356,7 @@ export class FishSingWorld implements World {
|
|
|
356
356
|
}
|
|
357
357
|
if (!test || !existsSync(test)) {
|
|
358
358
|
this.host?.log.warn('[fish-sing] 没找到可用的训练切片当测试句,跳过选模对比');
|
|
359
|
-
return;
|
|
359
|
+
return '';
|
|
360
360
|
}
|
|
361
361
|
const ts = new Date().toISOString().slice(0, 16).replace(/[-:T]/g, '');
|
|
362
362
|
const outDir = join(this.data().dataDir, 'ab', `${exp}-${ts}`);
|
|
@@ -401,6 +401,7 @@ export class FishSingWorld implements World {
|
|
|
401
401
|
`选模试听已生成:${exp}`,
|
|
402
402
|
`同一句训练切片,用 ${labels.join('、')} 各唱了一遍。在作品库里对比听(fish_sing_library)${obTarget ? ',QQ 那边也各发了一条' : ''}。`,
|
|
403
403
|
);
|
|
404
|
+
return labels.join(' / ');
|
|
404
405
|
}
|
|
405
406
|
|
|
406
407
|
private deps(): SingDeps {
|
|
@@ -987,6 +988,10 @@ export class FishSingWorld implements World {
|
|
|
987
988
|
rebuild?: boolean;
|
|
988
989
|
/** 训练完自动清理中间档(默认不勾:删了只能重训才拿得回来) */
|
|
989
990
|
pruneAfter?: boolean;
|
|
991
|
+
/** 训练完生成选模对比试听(默认开) */
|
|
992
|
+
abTest?: boolean;
|
|
993
|
+
/** 低音增强:合成 -2/-4 半音低音数据(默认开) */
|
|
994
|
+
augment?: boolean;
|
|
990
995
|
keepEvery?: number;
|
|
991
996
|
};
|
|
992
997
|
const dir = this.datasetJob?.dir;
|
|
@@ -1037,6 +1042,8 @@ export class FishSingWorld implements World {
|
|
|
1037
1042
|
saveEvery,
|
|
1038
1043
|
resume: cfg.resume === true,
|
|
1039
1044
|
rebuild: cfg.rebuild === true,
|
|
1045
|
+
// 低音增强:-2/-4 半音各合成一份低音数据,副本权重按份数摊薄(见 trainer.prepare)
|
|
1046
|
+
augmentShifts: cfg.augment === false ? [] : [-2, -4],
|
|
1040
1047
|
weightMap,
|
|
1041
1048
|
});
|
|
1042
1049
|
job.id = id;
|
|
@@ -1077,7 +1084,7 @@ export class FishSingWorld implements World {
|
|
|
1077
1084
|
}
|
|
1078
1085
|
}
|
|
1079
1086
|
void this.notifyEvent(`训练完成:${exp}`, `${epochs} 轮全部完成。${job.msg}`);
|
|
1080
|
-
void this.runAbTest(exp).catch((e: unknown) => {
|
|
1087
|
+
void this.runAbTest(exp, cfg.abTest !== false).catch((e: unknown) => {
|
|
1081
1088
|
this.host?.log.warn(`[fish-sing] 选模对比失败:${e instanceof Error ? e.message : String(e)}`);
|
|
1082
1089
|
});
|
|
1083
1090
|
})
|
|
@@ -1157,6 +1164,13 @@ export class FishSingWorld implements World {
|
|
|
1157
1164
|
};
|
|
1158
1165
|
}
|
|
1159
1166
|
|
|
1167
|
+
if (method === 'trainAbTest') {
|
|
1168
|
+
const exp = String(args[0]?.exp ?? '').trim() || this.trainJob?.exp || '';
|
|
1169
|
+
if (!exp) throw new Error('没有实验名:先在「训练」页填实验名,或跑一次训练');
|
|
1170
|
+
const text = await this.runAbTest(exp, true);
|
|
1171
|
+
return { text: text || `没生成:${exp} 只找到一个可用存档(中间档可能已被清理)` };
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1160
1174
|
if (method === 'trainStop') {
|
|
1161
1175
|
await this.worker.cancel();
|
|
1162
1176
|
if (this.trainJob?.state === 'running') {
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 发版一条龙:CHANGELOG 检查 → npm publish → 轮询 tarball 可用。
|
|
4
|
+
*
|
|
5
|
+
* 为什么不用裸 npm publish:
|
|
6
|
+
* · CHANGELOG 忘了写,用户不知道更新了啥(0.2.x 之前的教训,现在硬性拦截);
|
|
7
|
+
* · publish 显示成功 ≠ 注册表可下载——tarball CDN 有 404 窗口期,实测 2~6 分钟,
|
|
8
|
+
* 紧接着跑 pnpm add 会报 404(0.1.4~0.1.9 每个版本都踩了一遍);
|
|
9
|
+
* · E409(版本被 npm 暂存)时给出明确指引,而不是让人对着报错猜。
|
|
10
|
+
*
|
|
11
|
+
* 用法(在仓库根目录):
|
|
12
|
+
* node tools/publish.mjs # 发布 package.json 里的当前版本
|
|
13
|
+
* node tools/publish.mjs --check # 只检查 CHANGELOG,不发布
|
|
14
|
+
*
|
|
15
|
+
* 前置:npm 已登录(npx npm whoami 验证);CHANGELOG.md 里有 `## [当前版本]` 条目。
|
|
16
|
+
*/
|
|
17
|
+
import { readFileSync } from 'node:fs';
|
|
18
|
+
import { join, dirname } from 'node:path';
|
|
19
|
+
import { fileURLToPath } from 'node:url';
|
|
20
|
+
import { execSync } from 'node:child_process';
|
|
21
|
+
|
|
22
|
+
const ROOT = dirname(dirname(fileURLToPath(import.meta.url)));
|
|
23
|
+
const PKG = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8'));
|
|
24
|
+
const VERSION = PKG.version;
|
|
25
|
+
const NAME = PKG.name;
|
|
26
|
+
const CHANGELOG = join(ROOT, 'CHANGELOG.md');
|
|
27
|
+
|
|
28
|
+
const step = (m) => console.log(`\n==> ${m}`);
|
|
29
|
+
|
|
30
|
+
// ---- 1. CHANGELOG 检查 ------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
step(`检查 CHANGELOG(${NAME}@${VERSION})`);
|
|
33
|
+
const changelog = readFileSync(CHANGELOG, 'utf8');
|
|
34
|
+
if (!changelog.includes(`## [${VERSION}]`)) {
|
|
35
|
+
console.error(`✗ CHANGELOG.md 里没有 "## [${VERSION}]" 条目。`);
|
|
36
|
+
console.error(' 先把这一版改了什么写进去,再发版——别人要知道更新了啥。');
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
console.log('✓ CHANGELOG 条目在');
|
|
40
|
+
|
|
41
|
+
// --check 模式到此为止
|
|
42
|
+
if (process.argv.includes('--check')) {
|
|
43
|
+
console.log('\n--check 通过,未发布。');
|
|
44
|
+
process.exit(0);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// ---- 2. npm publish --------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
step('npm publish');
|
|
50
|
+
try {
|
|
51
|
+
execSync('npm publish --access public', { cwd: ROOT, stdio: 'inherit' });
|
|
52
|
+
} catch (e) {
|
|
53
|
+
const out = String(e.stdout || '') + String(e.stderr || '');
|
|
54
|
+
if (out.includes('E409') || out.includes('cannot be published') || out.includes(' 版本已被') || out.includes('staged')) {
|
|
55
|
+
console.error('✗ npm 拒绝了这个版本(可能被暂存,如 0.1.1 那次)。');
|
|
56
|
+
console.error(' 处理:升一个版本号(package.json + CHANGELOG)后重试本脚本。');
|
|
57
|
+
}
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
console.log(`✓ ${NAME}@${VERSION} 已提交到注册表`);
|
|
61
|
+
|
|
62
|
+
// ---- 3. 轮询 tarball 可用 --------------------------------------------------
|
|
63
|
+
|
|
64
|
+
const tarball = `https://registry.npmjs.org/${NAME}/-/${NAME}-${VERSION}.tgz`;
|
|
65
|
+
const POLL_MAX = 12; // 12 次 × 40 秒 ≈ 8 分钟,覆盖实测的 CDN 延迟
|
|
66
|
+
const POLL_EVERY = 40_000;
|
|
67
|
+
|
|
68
|
+
step(`轮询 tarball(${tarball})`);
|
|
69
|
+
let ok = false;
|
|
70
|
+
for (let i = 1; i <= POLL_MAX; i += 1) {
|
|
71
|
+
try {
|
|
72
|
+
const res = await fetch(tarball, { method: 'HEAD', signal: AbortSignal.timeout(30_000) });
|
|
73
|
+
console.log(` 第 ${i} 次:HTTP ${res.status}`);
|
|
74
|
+
if (res.status === 200) {
|
|
75
|
+
ok = true;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
} catch (e) {
|
|
79
|
+
console.log(` 第 ${i} 次:网络错误 ${e.message}`);
|
|
80
|
+
}
|
|
81
|
+
await new Promise((r) => setTimeout(r, POLL_EVERY));
|
|
82
|
+
}
|
|
83
|
+
if (!ok) {
|
|
84
|
+
console.error(`✗ ${POLL_MAX * (POLL_EVERY / 1000)} 秒后 tarball 仍 404。可能被暂存或 CDN 异常,稍后手动查:`);
|
|
85
|
+
console.error(` ${tarball}`);
|
|
86
|
+
process.exit(1);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// ---- 4. 收尾提醒 -----------------------------------------------------------
|
|
90
|
+
|
|
91
|
+
console.log(`
|
|
92
|
+
✓ ${NAME}@${VERSION} 发布完成,tarball 已可下载。
|
|
93
|
+
|
|
94
|
+
别忘了两件事:
|
|
95
|
+
1. 本机/反馈者升级:pnpm add ${NAME}@${VERSION}(受 minimumReleaseAge 限制的话,
|
|
96
|
+
把版本加进 pnpm-workspace.yaml 的 minimumReleaseAgeExclude);
|
|
97
|
+
2. 市场更新日志:索引仓的同步 Action 靠 [sync] issue 触发。市场里没显示的话,
|
|
98
|
+
去 Pal-AI-Lab/cortico-extensions 开一个标题为 "[sync] ${NAME}" 的空 issue。
|
|
99
|
+
`);
|
package/worker/trainer.py
CHANGED
|
@@ -119,12 +119,16 @@ def find_checkpoint(exp: str):
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
def prepare(exp, dataset_dir: Path, progress, cancel, keep_existing=True):
|
|
122
|
+
def prepare(exp, dataset_dir: Path, progress, cancel, keep_existing=True, augment_shifts=None, weights=None):
|
|
123
123
|
"""
|
|
124
124
|
建实验目录并把切片铺成 RVC 需要的三层结构。
|
|
125
125
|
|
|
126
126
|
- 0_gt_wavs:40k 原样(训练时读它算 mel)
|
|
127
127
|
- 1_16k_wavs:16k 单声道(F0 和 ContentVec 都只认这个)
|
|
128
|
+
|
|
129
|
+
augment_shifts:低音增强。给每个切片用 ffmpeg asetrate+atempo 合成降调副本
|
|
130
|
+
(如 [-2, -4] = 各降 2/4 个半音),一起铺进两层——模型由此学到低音区的音色映射。
|
|
131
|
+
副本命名 aug<shift>_<原名>.wav;weights 里的同名权重会按副本数摊薄(见 train_run)。
|
|
128
132
|
"""
|
|
129
133
|
exp_dir = exp_dir_of(exp)
|
|
130
134
|
exp_dir.mkdir(parents=True, exist_ok=True)
|
|
@@ -139,11 +143,39 @@ def prepare(exp, dataset_dir: Path, progress, cancel, keep_existing=True):
|
|
|
139
143
|
gt.mkdir(exist_ok=True)
|
|
140
144
|
hi.mkdir(exist_ok=True)
|
|
141
145
|
|
|
146
|
+
shifts = [int(s) for s in (augment_shifts or []) if int(s) != 0]
|
|
142
147
|
slices = sorted((dataset_dir / "slices").glob("*.wav"))
|
|
143
148
|
if not slices:
|
|
144
149
|
raise RuntimeError(f"{dataset_dir / 'slices'} 里没有切片,先跑数据准备")
|
|
145
150
|
total = len(slices)
|
|
146
|
-
log(f"切片 {total} 个 → {exp_dir}")
|
|
151
|
+
log(f"切片 {total} 个 → {exp_dir}" + (f",低音增强 {shifts}" if shifts else ""))
|
|
152
|
+
|
|
153
|
+
aug_made = 0
|
|
154
|
+
|
|
155
|
+
def lay_augmented(src: Path) -> None:
|
|
156
|
+
"""合成 src 的降调副本,铺进 0_gt/1_16k 两层。ffmpeg 子进程,不占 GIL。"""
|
|
157
|
+
nonlocal aug_made
|
|
158
|
+
try:
|
|
159
|
+
import soundfile as sf
|
|
160
|
+
sr_in = sf.info(str(src)).samplerate
|
|
161
|
+
except Exception: # noqa: BLE001
|
|
162
|
+
sr_in = 40000
|
|
163
|
+
for s in shifts:
|
|
164
|
+
name = f"aug{s}_{src.name}"
|
|
165
|
+
dst0 = gt / name
|
|
166
|
+
dst1 = hi / name
|
|
167
|
+
if dst0.exists() and dst1.exists():
|
|
168
|
+
continue
|
|
169
|
+
factor = 2 ** (s / 12)
|
|
170
|
+
tempo = 2 ** (-s / 12)
|
|
171
|
+
# 40k 副本:降调 + 补速度(asetrate 降调会拖长,atempo 拉回来)
|
|
172
|
+
run([FFMPEG, "-y", "-v", "error", "-i", str(src),
|
|
173
|
+
"-af", f"asetrate={sr_in}*{factor:.8f},aresample={sr_in},atempo={tempo:.8f}",
|
|
174
|
+
"-c:a", "pcm_s16le", str(dst0)], f"低音增强 {s} 半音")
|
|
175
|
+
# 16k 单声道副本:从 40k 副本重采样(跟原切片同一套流程)
|
|
176
|
+
run([FFMPEG, "-y", "-v", "error", "-i", str(dst0),
|
|
177
|
+
"-ac", "1", "-ar", "16000", "-c:a", "pcm_s16le", str(dst1)], "重采样 16k")
|
|
178
|
+
aug_made += 1
|
|
147
179
|
|
|
148
180
|
added = 0
|
|
149
181
|
for i, src in enumerate(slices):
|
|
@@ -160,9 +192,17 @@ def prepare(exp, dataset_dir: Path, progress, cancel, keep_existing=True):
|
|
|
160
192
|
if not dst1.exists():
|
|
161
193
|
run([FFMPEG, "-y", "-v", "error", "-i", str(src), "-ac", "1", "-ar", "16000",
|
|
162
194
|
"-c:a", "pcm_s16le", str(dst1)], "重采样 16k")
|
|
195
|
+
if shifts:
|
|
196
|
+
lay_augmented(src)
|
|
163
197
|
if i % 50 == 0 or i == total - 1:
|
|
164
|
-
progress(0.02 + 0.06 * ((i + 1) / total), f"铺切片 {i + 1}/{total}")
|
|
165
|
-
log(f"新增 {added} 个(已存在的跳过)")
|
|
198
|
+
progress(0.02 + 0.06 * ((i + 1) / total), f"铺切片 {i + 1}/{total}" + (f"(增强 {aug_made})" if shifts else ""))
|
|
199
|
+
log(f"新增 {added} 个(已存在的跳过)" + (f",低音增强副本 {aug_made} 个" if shifts else ""))
|
|
200
|
+
|
|
201
|
+
if shifts:
|
|
202
|
+
(exp_dir / "aug_manifest.json").write_text(
|
|
203
|
+
json.dumps({"shifts": shifts, "created": aug_made, "slices": total}, ensure_ascii=False),
|
|
204
|
+
encoding="utf8",
|
|
205
|
+
)
|
|
166
206
|
return exp_dir
|
|
167
207
|
|
|
168
208
|
|
|
@@ -234,11 +274,25 @@ def train_run(exp, dataset_dir, params, progress, cancel, weights=None):
|
|
|
234
274
|
"""
|
|
235
275
|
完整流水线。params:
|
|
236
276
|
epochs / batch / saveEvery / resume(bool) / fromG / fromD / rebuild(bool)
|
|
277
|
+
augmentShifts([int]):低音增强,如 [-2, -4](合成降调副本,见 prepare)
|
|
237
278
|
"""
|
|
238
279
|
t0 = time.time()
|
|
239
|
-
|
|
280
|
+
augment_shifts = [int(s) for s in (params.get("augmentShifts") or [])]
|
|
281
|
+
exp_dir = prepare(exp, Path(dataset_dir), progress, cancel,
|
|
282
|
+
augment_shifts=augment_shifts, weights=weights)
|
|
240
283
|
total = count_files(exp_dir / "0_gt_wavs", ".wav")
|
|
241
284
|
|
|
285
|
+
# 增强副本继承源切片权重,但按「源 + 副本」的总份数摊薄:
|
|
286
|
+
# 低音 3x 的源片 + 2 个副本 → 各 1x,总重要度还是 3x,材料时长翻了 3 倍。
|
|
287
|
+
if augment_shifts and weights:
|
|
288
|
+
div = len(augment_shifts) + 1
|
|
289
|
+
expanded = dict(weights)
|
|
290
|
+
for s in augment_shifts:
|
|
291
|
+
for k, v in weights.items():
|
|
292
|
+
expanded[f"aug{s}_{k}"] = float(v) / div
|
|
293
|
+
weights = expanded
|
|
294
|
+
log(f"权重已扩展到增强副本(÷{div})")
|
|
295
|
+
|
|
242
296
|
rebuild = bool(params.get("rebuild", False))
|
|
243
297
|
|
|
244
298
|
# ---- F0
|