cortico-world-fish-sing 0.4.11 → 0.4.13

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 CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/);版本号遵循语义化。
4
4
 
5
+ ## [0.4.13] - 2026-11-03
6
+
7
+ ### 改进
8
+ - **训练页重排成三步折叠**:① 素材 → 数据集(放歌、扫描、切片)/② 训练(参数、勾选、进度、loss 曲线、模型、清理)/③ 高级:低音增强 / 音域加权(默认收起)。之前是十来个 bar 平铺,新用户第一眼看到路径、数据集、实验、参数、5 个勾选、低音滑块、进度、曲线、清理——不知道该从哪下手。
9
+ - 实验名给默认值(`fishMMDD`),不用再卡在"实验名填什么"。
10
+ - 「进程不由面板接管」的训练(重启前留下的)也显示预计剩余时间。
11
+
12
+ ## [0.4.12] - 2026-11-03
13
+
14
+ ### 修复
15
+ - **变调只改人声、伴奏留在原调**:pitch≠0 时人声被移调、伴奏却不动,两者相差 N 个半音(三全音是最刺耳的那档)。听感是「这版听着怪、说不上哪儿不对」,唱男声歌几乎必中(自动变调会给 +6)。现在**伴奏同步变调**(`asetrate` + `aresample` + `atempo`,保持时长),整首歌一起移调,等于正常的升调/降调翻唱。
16
+ - 用户实测确认:同一段《山丘》+6,B 版(伴奏一起移)明显更好听。
17
+ - 新增单测:变调滤镜的倍率必须等于 2^(n/12)、atempo 必须是其倒数。
18
+
5
19
  ## [0.4.11] - 2026-11-03
6
20
 
7
21
  ### 修复
@@ -664,6 +664,17 @@ function mountModels(ctx) {
664
664
 
665
665
  const TRAIN_STYLE_ID = 'fish-sing-train-style';
666
666
  const TRAIN_CSS = `
667
+ /* 分步折叠:新用户只看得到当前该做什么,老手展开就有全部东西 */
668
+ .fs-sec{margin:10px 0;border:1px solid rgba(127,127,127,.22);border-radius:10px;
669
+ background:rgba(127,127,127,.035);overflow:hidden}
670
+ .fs-sec>summary{cursor:pointer;padding:9px 12px;font-size:13px;font-weight:600;
671
+ display:flex;align-items:center;gap:8px;list-style:none;user-select:none}
672
+ .fs-sec>summary::-webkit-details-marker{display:none}
673
+ .fs-sec>summary::before{content:"▸";opacity:.55;font-size:11px;transition:transform .12s}
674
+ .fs-sec[open]>summary::before{transform:rotate(90deg)}
675
+ .fs-sec>summary:hover{background:rgba(127,127,127,.07)}
676
+ .fs-sec-hint{font-weight:400;font-size:11.5px;opacity:.55}
677
+ .fs-sec-body{padding:2px 12px 12px}
667
678
  .fs-tpath{flex:1;min-width:280px;padding:5px 8px;border-radius:6px;
668
679
  border:1px solid rgba(127,127,127,.35);background:transparent;color:inherit;font-size:12.5px}
669
680
  .fs-tsum{font-size:12.5px;line-height:1.7}
@@ -777,7 +788,30 @@ function mountTrain(ctx) {
777
788
  const weightBox = el('div', '');
778
789
 
779
790
  const trainBox = el('div', '');
780
- root.append(bar, dsBar, importBar, bar2, prog, msg, listBox, resultBox, weightBox, trainBox);
791
+
792
+ // ---- 分步折叠布局:①素材 ②训练 ③高级 ------------------------------
793
+ // 之前这里是把 10 个 bar/box 平铺,新用户第一眼看到素材路径、数据集、实验、
794
+ // 参数、5 个勾选、低音滑块、进度、曲线、清理——完全不知道从哪下手。
795
+ const mkSec = (title, hint, open) => {
796
+ const d = el('details', 'fs-sec');
797
+ if (open) d.open = true;
798
+ const sum = el('summary', '');
799
+ sum.append(el('span', '', title), el('span', 'fs-sec-hint', hint));
800
+ const body = el('div', 'fs-sec-body');
801
+ d.append(sum, body);
802
+ return { d, body };
803
+ };
804
+
805
+ const secA = mkSec('① 素材 → 数据集', '把歌放进来、扫描、切成训练用的片', true);
806
+ secA.body.append(bar, bar2, listBox, resultBox, dsBar, importBar);
807
+
808
+ const secB = mkSec('② 训练', '一般只需要改「轮次」,其余都在展开项里', true);
809
+ secB.body.append(trainBox);
810
+
811
+ const secC = mkSec('③ 高级:低音增强 / 音域加权', '给数据加降调副本、按音域调采样权重(有效但有限)', false);
812
+ secC.body.append(weightBox);
813
+
814
+ root.append(prog, msg, secA.d, secB.d, secC.d);
781
815
 
782
816
  let items = [];
783
817
  let checked = new Set();
@@ -1153,6 +1187,13 @@ function mountTrain(ctx) {
1153
1187
  const tForm = el('div', 'fs-tform');
1154
1188
  const expIn = el('input', 'fs-tin');
1155
1189
  expIn.placeholder = '实验名(英文,如 fish1029)';
1190
+ // 给个默认名,别让新用户卡在"实验名填什么"这一步(同名会复用目录,所以带日期)
1191
+ {
1192
+ const d = new Date();
1193
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
1194
+ const dd = String(d.getDate()).padStart(2, '0');
1195
+ expIn.value = `fish${mm}${dd}`;
1196
+ }
1156
1197
  const epIn = el('input', 'fs-tin');
1157
1198
  epIn.type = 'number';
1158
1199
  epIn.min = '10';
@@ -1361,7 +1402,9 @@ function mountTrain(ctx) {
1361
1402
 
1362
1403
  if (running && !job) {
1363
1404
  const per = log.secPerEpoch ? ` · ${log.secPerEpoch.toFixed(0)} 秒/轮` : '';
1364
- tMsg.textContent = `训练中(日志 ${st.logAgeSec} 秒前更新,进程不由面板接管):${log.done}/${total || '?'} 轮${per}`;
1405
+ const left = log.secPerEpoch && total ? Math.max(0, total - log.done) * log.secPerEpoch : 0;
1406
+ const eta = left ? ` · 预计还要 ${fmtDur(left)}` : '';
1407
+ tMsg.textContent = `训练中(日志 ${st.logAgeSec} 秒前更新,进程不由面板接管):${log.done}/${total || '?'} 轮${per}${eta}`;
1365
1408
  tMsg.classList.remove('bad');
1366
1409
  } else if (running) {
1367
1410
  const eta = st.etaSec ? ` · 预计还要 ${fmtDur(st.etaSec)}` : '';
package/dist/webui.js CHANGED
@@ -664,6 +664,17 @@ function mountModels(ctx) {
664
664
 
665
665
  const TRAIN_STYLE_ID = 'fish-sing-train-style';
666
666
  const TRAIN_CSS = `
667
+ /* 分步折叠:新用户只看得到当前该做什么,老手展开就有全部东西 */
668
+ .fs-sec{margin:10px 0;border:1px solid rgba(127,127,127,.22);border-radius:10px;
669
+ background:rgba(127,127,127,.035);overflow:hidden}
670
+ .fs-sec>summary{cursor:pointer;padding:9px 12px;font-size:13px;font-weight:600;
671
+ display:flex;align-items:center;gap:8px;list-style:none;user-select:none}
672
+ .fs-sec>summary::-webkit-details-marker{display:none}
673
+ .fs-sec>summary::before{content:"▸";opacity:.55;font-size:11px;transition:transform .12s}
674
+ .fs-sec[open]>summary::before{transform:rotate(90deg)}
675
+ .fs-sec>summary:hover{background:rgba(127,127,127,.07)}
676
+ .fs-sec-hint{font-weight:400;font-size:11.5px;opacity:.55}
677
+ .fs-sec-body{padding:2px 12px 12px}
667
678
  .fs-tpath{flex:1;min-width:280px;padding:5px 8px;border-radius:6px;
668
679
  border:1px solid rgba(127,127,127,.35);background:transparent;color:inherit;font-size:12.5px}
669
680
  .fs-tsum{font-size:12.5px;line-height:1.7}
@@ -777,7 +788,30 @@ function mountTrain(ctx) {
777
788
  const weightBox = el('div', '');
778
789
 
779
790
  const trainBox = el('div', '');
780
- root.append(bar, dsBar, importBar, bar2, prog, msg, listBox, resultBox, weightBox, trainBox);
791
+
792
+ // ---- 分步折叠布局:①素材 ②训练 ③高级 ------------------------------
793
+ // 之前这里是把 10 个 bar/box 平铺,新用户第一眼看到素材路径、数据集、实验、
794
+ // 参数、5 个勾选、低音滑块、进度、曲线、清理——完全不知道从哪下手。
795
+ const mkSec = (title, hint, open) => {
796
+ const d = el('details', 'fs-sec');
797
+ if (open) d.open = true;
798
+ const sum = el('summary', '');
799
+ sum.append(el('span', '', title), el('span', 'fs-sec-hint', hint));
800
+ const body = el('div', 'fs-sec-body');
801
+ d.append(sum, body);
802
+ return { d, body };
803
+ };
804
+
805
+ const secA = mkSec('① 素材 → 数据集', '把歌放进来、扫描、切成训练用的片', true);
806
+ secA.body.append(bar, bar2, listBox, resultBox, dsBar, importBar);
807
+
808
+ const secB = mkSec('② 训练', '一般只需要改「轮次」,其余都在展开项里', true);
809
+ secB.body.append(trainBox);
810
+
811
+ const secC = mkSec('③ 高级:低音增强 / 音域加权', '给数据加降调副本、按音域调采样权重(有效但有限)', false);
812
+ secC.body.append(weightBox);
813
+
814
+ root.append(prog, msg, secA.d, secB.d, secC.d);
781
815
 
782
816
  let items = [];
783
817
  let checked = new Set();
@@ -1153,6 +1187,13 @@ function mountTrain(ctx) {
1153
1187
  const tForm = el('div', 'fs-tform');
1154
1188
  const expIn = el('input', 'fs-tin');
1155
1189
  expIn.placeholder = '实验名(英文,如 fish1029)';
1190
+ // 给个默认名,别让新用户卡在"实验名填什么"这一步(同名会复用目录,所以带日期)
1191
+ {
1192
+ const d = new Date();
1193
+ const mm = String(d.getMonth() + 1).padStart(2, '0');
1194
+ const dd = String(d.getDate()).padStart(2, '0');
1195
+ expIn.value = `fish${mm}${dd}`;
1196
+ }
1156
1197
  const epIn = el('input', 'fs-tin');
1157
1198
  epIn.type = 'number';
1158
1199
  epIn.min = '10';
@@ -1361,7 +1402,9 @@ function mountTrain(ctx) {
1361
1402
 
1362
1403
  if (running && !job) {
1363
1404
  const per = log.secPerEpoch ? ` · ${log.secPerEpoch.toFixed(0)} 秒/轮` : '';
1364
- tMsg.textContent = `训练中(日志 ${st.logAgeSec} 秒前更新,进程不由面板接管):${log.done}/${total || '?'} 轮${per}`;
1405
+ const left = log.secPerEpoch && total ? Math.max(0, total - log.done) * log.secPerEpoch : 0;
1406
+ const eta = left ? ` · 预计还要 ${fmtDur(left)}` : '';
1407
+ tMsg.textContent = `训练中(日志 ${st.logAgeSec} 秒前更新,进程不由面板接管):${log.done}/${total || '?'} 轮${per}${eta}`;
1365
1408
  tMsg.classList.remove('bad');
1366
1409
  } else if (running) {
1367
1410
  const eta = st.etaSec ? ` · 预计还要 ${fmtDur(st.etaSec)}` : '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cortico-world-fish-sing",
3
- "version": "0.4.11",
3
+ "version": "0.4.13",
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-efe43ccf.js"
39
+ "webUiClient": "dist/webui-554b9bbb.js"
40
40
  },
41
41
  "scripts": {
42
42
  "doctor": "node tools/doctor.mjs"
@@ -126,5 +126,17 @@ class AugmentWeightExpansion(unittest.TestCase):
126
126
  self.assertIn(f"aug{shift}_slice001.wav", e)
127
127
 
128
128
 
129
+ def test_pitch_shift_filter_keeps_ratio(self):
130
+ # 变调滤镜:asetrate 的倍率必须等于 2^(n/12),atempo 必须是它的倒数(保时长)
131
+ import re as _re
132
+ for semi in (6, -5, 3):
133
+ flt = engine.SingEngine.pitch_shift_filter(44100, semi)
134
+ m = _re.search(r'asetrate=(\d+)', flt)
135
+ t = _re.search(r'atempo=([\d.]+)', flt)
136
+ self.assertIsNotNone(m, flt)
137
+ ratio = int(m.group(1)) / 44100
138
+ self.assertAlmostEqual(ratio, 2 ** (semi / 12), places=3)
139
+ self.assertAlmostEqual(float(t.group(1)), 1 / ratio, places=3)
140
+
129
141
  if __name__ == "__main__":
130
142
  unittest.main()
package/worker/engine.py CHANGED
@@ -746,9 +746,22 @@ class SingEngine:
746
746
  shutil.copyfile(conv, out)
747
747
  mix_info = {"sr": info["sr"], "seconds": info["seconds"]}
748
748
  else:
749
+ inst_for_mix = inst
750
+ if pitch and inst is not None:
751
+ # 整体变调:伴奏必须跟着一起移,否则人声和伴奏差 N 个半音。
752
+ # (0.4.12 之前的真实问题:pitch≠0 时"听着怪但说不出哪不对",
753
+ # 唱男声歌几乎必中——自动变调会给 +6,伴奏却一直在原调。)
754
+ report(0.82, f"伴奏同步变调 {pitch:+d} 半音")
755
+ inst_for_mix = work / "inst_shifted.wav"
756
+ try:
757
+ sr_i = int(sf.info(str(inst)).samplerate)
758
+ except Exception: # noqa: BLE001
759
+ sr_i = 44100
760
+ run_ff([FFMPEG, "-y", "-hide_banner", "-loglevel", "error", "-i", str(inst),
761
+ "-af", self.pitch_shift_filter(sr_i, pitch), str(inst_for_mix)])
749
762
  report(0.85, "混音")
750
763
  out = work / "result.wav"
751
- mix_info = self.mix(conv, inst, out)
764
+ mix_info = self.mix(conv, inst_for_mix, out)
752
765
 
753
766
  report(1.0, "完成")
754
767
  result = {
@@ -764,6 +777,17 @@ class SingEngine:
764
777
  result["pitchSuggest"] = suggestion
765
778
  return result
766
779
 
780
+ @staticmethod
781
+ def pitch_shift_filter(sr: int, semitones: float) -> str:
782
+ """
783
+ 变调但**保持时长**的 ffmpeg 滤镜串。
784
+
785
+ asetrate 改采样率等价于"升调+加速",所以后面必须用 atempo 把时长拉回来
786
+ (atempo=1/factor)。这样人声/伴奏都能整段移调而不改变节奏。
787
+ """
788
+ f = 2.0 ** (float(semitones) / 12.0)
789
+ return f"asetrate={int(round(sr * f))},aresample={sr},atempo={1.0 / f:.6f}"
790
+
767
791
  # -- 选模对比试听 -----------------------------------------------
768
792
 
769
793
  def ab_test(self, test: Path, out_dir: Path, variants: list, *, pitch: int = 0,