cortico-world-fish-sing 0.2.0 → 0.3.0
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 +15 -0
- package/dist/{webui-39b0a58f.js → webui-47b496dd.js} +30 -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
|
@@ -2,6 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循语义化。
|
|
4
4
|
|
|
5
|
+
## [0.3.0] - 2026-11-01
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
- **低音增强(治"低音不像"的根本手段)**:训练时把每个切片用 ffmpeg 合成 -2/-4 半音的低音数据一起训练,模型由此学到低音区的音色映射,不再只靠采样加权硬顶。训练页勾选框「低音增强」(默认开)。
|
|
9
|
+
- 副本命名 `aug<shift>_<原名>`,与原切片一起铺进 F0/特征两层;
|
|
10
|
+
- 采样权重按「源 + 副本」总份数摊薄(3x 低音源 + 2 副本 → 各 1x),避免与加权叠加成 9x 过采样;
|
|
11
|
+
- 实测:415Hz 切片的 -2/-4 副本基频 370/329Hz,精确命中理论值。
|
|
12
|
+
- 代价:F0/特征提取时间约 ×3(数据量 ×3)。
|
|
13
|
+
- **发版脚本 `tools/publish.mjs`**:CHANGELOG 缺条目硬性拦截 → npm publish → 轮询 tarball 可用(覆盖 2~6 分钟 CDN 延迟)→ 收尾提醒。`--check` 只查不发。
|
|
14
|
+
|
|
15
|
+
## [0.2.1] - 2026-11-01
|
|
16
|
+
|
|
17
|
+
### 新增
|
|
18
|
+
- **选模对比进面板 + 手动入口**:训练页新增勾选框「训练完生成选模对比」(默认勾)与「生成选模对比」按钮(对实验名里的实验手动跑一次,前提是还有中间档)。此前该功能只有 config.json 字段且纯自动触发,界面上完全不可见。
|
|
19
|
+
|
|
5
20
|
## [0.2.0] - 2026-11-01
|
|
6
21
|
|
|
7
22
|
### 新增
|
|
@@ -1199,7 +1199,13 @@ 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
|
+
chkRow.append(resumeLbl, rebuildLbl, pruneAfterLbl, abLbl, el('span', 'fs-grow'), startT, stopT);
|
|
1203
1209
|
|
|
1204
1210
|
const tProg = el('div', 'fs-prog');
|
|
1205
1211
|
const tFill = el('i');
|
|
@@ -1219,8 +1225,10 @@ function mountTrain(ctx) {
|
|
|
1219
1225
|
keepIn.style.width = '64px';
|
|
1220
1226
|
const pruneBtn = el('button', 'fs-btn', '清理中间档');
|
|
1221
1227
|
pruneBtn.title = '只删 assets/weights/<exp>_eN_sX.pth 这种导出的小模型;完整存档、索引、最终模型都不动';
|
|
1228
|
+
const abBtn = el('button', 'fs-btn', '生成选模对比');
|
|
1229
|
+
abBtn.title = '用当前实验的存档(final + 最后两个中间档)各唱同一句训练切片,生成对比试听进作品库';
|
|
1222
1230
|
ckptBar.append(el('span', 'fs-meta', '中间档:'), ckptMeta, el('span', 'fs-meta', '每'),
|
|
1223
|
-
keepIn, el('span', 'fs-meta', '轮留一个'), el('span', 'fs-grow'), pruneBtn);
|
|
1231
|
+
keepIn, el('span', 'fs-meta', '轮留一个'), el('span', 'fs-grow'), abBtn, pruneBtn);
|
|
1224
1232
|
trainBox.append(tTitle, tForm, chkRow, tProg, tMsg, losses, lossAxis, tModels, ckptBar);
|
|
1225
1233
|
|
|
1226
1234
|
let trainExp = '';
|
|
@@ -1236,6 +1244,25 @@ function mountTrain(ctx) {
|
|
|
1236
1244
|
} catch { /* 忽略 */ }
|
|
1237
1245
|
};
|
|
1238
1246
|
|
|
1247
|
+
abBtn.addEventListener('click', async () => {
|
|
1248
|
+
const exp = String(expIn.value || '').trim() || trainExp;
|
|
1249
|
+
if (!exp) {
|
|
1250
|
+
tMsg.textContent = '先填实验名(或跑一次训练)再生成选模对比';
|
|
1251
|
+
return;
|
|
1252
|
+
}
|
|
1253
|
+
abBtn.disabled = true;
|
|
1254
|
+
abBtn.textContent = '生成中…';
|
|
1255
|
+
try {
|
|
1256
|
+
const r = await ctx.invoke('trainAbTest', [{ exp }]);
|
|
1257
|
+
tMsg.textContent = (r && r.text) || `选模对比已生成(${exp})`;
|
|
1258
|
+
} catch (e) {
|
|
1259
|
+
tMsg.textContent = `选模对比失败:${(e && e.message) || e}`;
|
|
1260
|
+
} finally {
|
|
1261
|
+
abBtn.disabled = false;
|
|
1262
|
+
abBtn.textContent = '生成选模对比';
|
|
1263
|
+
}
|
|
1264
|
+
});
|
|
1265
|
+
|
|
1239
1266
|
pruneBtn.addEventListener('click', async () => {
|
|
1240
1267
|
if (!trainExp) return;
|
|
1241
1268
|
const step = Math.max(1, Number(keepIn.value) || 50);
|
|
@@ -1408,6 +1435,7 @@ function mountTrain(ctx) {
|
|
|
1408
1435
|
resume: resumeChk.checked,
|
|
1409
1436
|
rebuild: rebuildChk.checked,
|
|
1410
1437
|
pruneAfter: pruneAfterChk.checked,
|
|
1438
|
+
abTest: abChk.checked,
|
|
1411
1439
|
keepEvery: Math.max(1, Number(keepIn.value) || 50),
|
|
1412
1440
|
}]);
|
|
1413
1441
|
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.0",
|
|
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-47b496dd.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
|