cortico-world-fish-sing 0.4.20 → 0.4.21
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 +14 -0
- package/package.json +1 -1
- package/src/config.ts +19 -0
- package/src/library.ts +2 -0
- package/src/sing.ts +11 -0
- package/src/world.ts +7 -0
- package/tests/smoke.mjs +8 -0
- package/tests/test_engine_logic.py +9 -0
- package/worker/engine.py +5 -3
- package/worker/server.py +4 -0
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.21] - 2026-11-06
|
|
6
|
+
|
|
7
|
+
### 新增
|
|
8
|
+
- **「音量跟随 rms-mix-rate」可配置**(设置 → 大肥鱼唱歌 → 换声):轻唱、渐弱能不能还原全看它。
|
|
9
|
+
- `0` = 完全跟随原唱的音量起伏(**新默认**,用户实测温柔原唱用它最好听)
|
|
10
|
+
- `0.25` = 保留一点模型自己的动态(RVC 官方默认)
|
|
11
|
+
- `0.5+` = 轻唱被"唱满",渐弱消失
|
|
12
|
+
- `1` = 完全不跟随(**老版本的默认值,现已废弃**)
|
|
13
|
+
- 点歌工具 `fish_sing_song` 也加了同名可选参数 `rmsMixRate`,可以单首歌覆盖。
|
|
14
|
+
|
|
15
|
+
### 修复
|
|
16
|
+
- **翻唱丢失"轻唱/渐弱"**:`engine.convert()` 的 `rms_mix_rate` 默认值是 `1.0`,而 RVC 里 `1` 表示"**跳过**音量包络对齐"(`if rms_mix_rate != 1` 直接跳过),所以模型一直用自己的音量唱——温柔段落被唱满。《雨爱》实测:原唱结尾比副歌轻 5.0 dB,旧版只轻 3.0 dB,改成 0 后回到 5.0 dB。
|
|
17
|
+
- `ab_test`(选模对比)也改用 0.0,对比时听到的是真实动态。
|
|
18
|
+
|
|
5
19
|
## [0.4.20] - 2026-11-05
|
|
6
20
|
|
|
7
21
|
### 修复
|
package/package.json
CHANGED
package/src/config.ts
CHANGED
|
@@ -29,6 +29,11 @@ export interface FishSingConfigSection {
|
|
|
29
29
|
protect: number;
|
|
30
30
|
/** 半音数;'auto' = 每次按源曲与模型音域自动推荐 */
|
|
31
31
|
pitch: number | 'auto';
|
|
32
|
+
/**
|
|
33
|
+
* 音量包络跟随原唱的程度(RVC 的 rms_mix_rate):
|
|
34
|
+
* 0 = 完全跟随原唱(轻唱就是轻唱);1 = 完全用模型自己的音量(轻唱会被唱满)。
|
|
35
|
+
*/
|
|
36
|
+
rmsMixRate: number;
|
|
32
37
|
/** full = 带伴奏;vocals = 只要人声 */
|
|
33
38
|
mode: 'full' | 'vocals';
|
|
34
39
|
};
|
|
@@ -101,6 +106,9 @@ export const FISHSING_DEFAULTS: FishSingConfigSection = {
|
|
|
101
106
|
indexRate: 0.75,
|
|
102
107
|
protect: 0.33,
|
|
103
108
|
pitch: 'auto',
|
|
109
|
+
// 0 = 严格跟随原唱的音量起伏。用户实测:温柔的原唱用 0 最好听;
|
|
110
|
+
// 老版本这里是 1.0(等于放弃跟随),轻唱段落会被唱满。
|
|
111
|
+
rmsMixRate: 0,
|
|
104
112
|
mode: 'full',
|
|
105
113
|
},
|
|
106
114
|
play: {
|
|
@@ -189,6 +197,17 @@ export function fishsingConfigGroups(): ConfigGroup[] {
|
|
|
189
197
|
description: "填 'auto' = 每首歌按源曲与模型音域自动推荐(默认,推荐)。填数字 = 固定移调;男歌女唱常要 +2 ~ +4。",
|
|
190
198
|
'x-hot': true,
|
|
191
199
|
},
|
|
200
|
+
[at('voice.rmsMixRate')]: {
|
|
201
|
+
type: 'number',
|
|
202
|
+
title: '音量跟随 rms-mix-rate',
|
|
203
|
+
description:
|
|
204
|
+
'轻唱/渐弱能不能还原,全看这个。0 = 完全跟随原唱的音量起伏(推荐,温柔的歌用它最好听);'
|
|
205
|
+
+ '0.25 = 保留一点模型自己的动态(RVC 官方默认);'
|
|
206
|
+
+ '0.5 以上轻唱会被"唱满",渐弱基本消失;1 = 完全不跟随(老版本的行为,已废弃)。',
|
|
207
|
+
minimum: 0,
|
|
208
|
+
maximum: 1,
|
|
209
|
+
'x-hot': true,
|
|
210
|
+
},
|
|
192
211
|
[at('voice.mode')]: {
|
|
193
212
|
type: 'string',
|
|
194
213
|
title: '默认输出',
|
package/src/library.ts
CHANGED
package/src/sing.ts
CHANGED
|
@@ -48,6 +48,12 @@ export interface SingDeps {
|
|
|
48
48
|
voice: SingParams;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/** 把 0~1 之间的参数夹住:非法/越界一律退回配置值,别把 NaN 传到 worker。 */
|
|
52
|
+
function clamp01(v: unknown): number {
|
|
53
|
+
const n = Number(v);
|
|
54
|
+
return Number.isFinite(n) ? Math.min(1, Math.max(0, n)) : 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
51
57
|
export interface SingRequest {
|
|
52
58
|
song: string;
|
|
53
59
|
to?: string;
|
|
@@ -56,6 +62,8 @@ export interface SingRequest {
|
|
|
56
62
|
pitch?: number | 'auto';
|
|
57
63
|
indexRate?: number;
|
|
58
64
|
protect?: number;
|
|
65
|
+
/** 音量跟随原唱的程度 0~1(0 = 完全跟随,轻唱不会被唱满) */
|
|
66
|
+
rmsMixRate?: number;
|
|
59
67
|
start?: number;
|
|
60
68
|
duration?: number;
|
|
61
69
|
/** 跳过缓存(想重唱一遍时用) */
|
|
@@ -260,6 +268,8 @@ export async function singSong(req: SingRequest, deps: SingDeps): Promise<SingRe
|
|
|
260
268
|
index: deps.voice.index,
|
|
261
269
|
indexRate: Number(req.indexRate ?? deps.voice.indexRate),
|
|
262
270
|
protect: Number(req.protect ?? deps.voice.protect),
|
|
271
|
+
// 0 = 完全跟随原唱音量;1 = 完全用模型自己的(轻唱被唱满)。越界/NaN 一律退回配置值。
|
|
272
|
+
rmsMixRate: clamp01(req.rmsMixRate ?? deps.voice.rmsMixRate),
|
|
263
273
|
// 不传 pitch = 按配置默认(配置默认 'auto' = 按音域自动推荐)
|
|
264
274
|
pitch: req.pitch === undefined || req.pitch === 'auto'
|
|
265
275
|
? (deps.voice.pitch ?? 'auto')
|
|
@@ -308,6 +318,7 @@ export async function singSong(req: SingRequest, deps: SingDeps): Promise<SingRe
|
|
|
308
318
|
pitch: params.pitch,
|
|
309
319
|
index_rate: params.indexRate,
|
|
310
320
|
protect: params.protect,
|
|
321
|
+
rms_mix_rate: params.rmsMixRate,
|
|
311
322
|
});
|
|
312
323
|
let lastLog = 0;
|
|
313
324
|
const job = await deps.worker.wait(jobId, (p, msg) => {
|
package/src/world.ts
CHANGED
|
@@ -461,6 +461,7 @@ export class FishSingWorld implements World {
|
|
|
461
461
|
indexRate: Number(cfg.voice?.indexRate ?? 0.75),
|
|
462
462
|
protect: Number(cfg.voice?.protect ?? 0.33),
|
|
463
463
|
pitch: (cfg.voice?.pitch as number | 'auto' | undefined) ?? 'auto',
|
|
464
|
+
rmsMixRate: cfg.voice?.rmsMixRate === undefined ? 0 : Number(cfg.voice.rmsMixRate),
|
|
464
465
|
mode: cfg.voice?.mode === 'vocals' ? 'vocals' : 'full',
|
|
465
466
|
},
|
|
466
467
|
};
|
|
@@ -542,6 +543,11 @@ export class FishSingWorld implements World {
|
|
|
542
543
|
duration: { type: 'number', description: '唱多长(秒);配合 start 可只发一段' },
|
|
543
544
|
refresh: { type: 'boolean', description: '忽略缓存重唱一遍' },
|
|
544
545
|
search: { type: 'boolean', description: '只搜索不下载,返回候选列表(标题/时长/UP主/播放/BV)让你自己挑' },
|
|
546
|
+
rmsMixRate: {
|
|
547
|
+
type: 'number',
|
|
548
|
+
description: '音量跟随原唱的程度 0~1:0 = 完全跟随(轻唱/渐弱能还原,默认);'
|
|
549
|
+
+ '0.25 = 保留一点模型自己的动态;1 = 不跟随(轻唱会被唱满)。不确定就别传。',
|
|
550
|
+
},
|
|
545
551
|
pick: { type: 'string', description: '选定第几条:序号(从 1 开始)或 BV 号;配合 search 使用' },
|
|
546
552
|
order: {
|
|
547
553
|
type: 'string',
|
|
@@ -568,6 +574,7 @@ export class FishSingWorld implements World {
|
|
|
568
574
|
: String(args.pitch).toLowerCase() === 'auto' ? 'auto' : Number(args.pitch),
|
|
569
575
|
indexRate: args.indexRate === undefined ? undefined : Number(args.indexRate),
|
|
570
576
|
protect: args.protect === undefined ? undefined : Number(args.protect),
|
|
577
|
+
rmsMixRate: args.rmsMixRate === undefined ? undefined : Number(args.rmsMixRate),
|
|
571
578
|
start: args.start === undefined ? undefined : Number(args.start),
|
|
572
579
|
duration: args.duration === undefined ? undefined : Number(args.duration),
|
|
573
580
|
refresh: args.refresh === true,
|
package/tests/smoke.mjs
CHANGED
|
@@ -52,6 +52,14 @@ const t1 = parseTarget('2587509374');
|
|
|
52
52
|
check('裸号码 → 私聊', Boolean(t1) && t1.action === 'send_private_msg' && t1.params.user_id === 2587509374);
|
|
53
53
|
check('乱码 → null', parseTarget('2587509374abc') === null);
|
|
54
54
|
|
|
55
|
+
// ---- 6. 音量跟随:默认 0(跟随原唱),且配置里有这一项 ----
|
|
56
|
+
const { FISHSING_DEFAULTS, fishsingConfigGroups } = await import('../src/config.ts');
|
|
57
|
+
check('默认 rmsMixRate = 0', FISHSING_DEFAULTS.voice.rmsMixRate === 0);
|
|
58
|
+
const voiceGroup = fishsingConfigGroups().find((g) => g.id.endsWith('.voice'));
|
|
59
|
+
const key = Object.keys(voiceGroup.schema.properties).find((k) => k.endsWith('voice.rmsMixRate'));
|
|
60
|
+
check('配置项 voice.rmsMixRate 存在', Boolean(key));
|
|
61
|
+
check('配置项有说明文案', String(voiceGroup.schema.properties[key].description || '').length > 20);
|
|
62
|
+
|
|
55
63
|
if (failed) {
|
|
56
64
|
console.error(`\n${failed} 项失败`);
|
|
57
65
|
process.exit(1);
|
|
@@ -138,5 +138,14 @@ class AugmentWeightExpansion(unittest.TestCase):
|
|
|
138
138
|
self.assertAlmostEqual(ratio, 2 ** (semi / 12), places=3)
|
|
139
139
|
self.assertAlmostEqual(float(t.group(1)), 1 / ratio, places=3)
|
|
140
140
|
|
|
141
|
+
def test_rms_mix_default_follows_source(self):
|
|
142
|
+
# rms_mix_rate=0 才等于"音量跟随原唱";1 在 RVC 里是"不做对齐"(轻唱会被唱满)。
|
|
143
|
+
# 老版本默认 1.0 导致所有翻唱的渐弱消失,这里钉住默认值,别再改回去。
|
|
144
|
+
import inspect
|
|
145
|
+
for fn in (engine.SingEngine.convert, engine.SingEngine.song):
|
|
146
|
+
sig = inspect.signature(fn)
|
|
147
|
+
self.assertIn('rms_mix_rate', sig.parameters, f'{fn.__name__} 少了 rms_mix_rate')
|
|
148
|
+
self.assertEqual(sig.parameters['rms_mix_rate'].default, 0.0, f'{fn.__name__} 默认值应为 0.0')
|
|
149
|
+
|
|
141
150
|
if __name__ == "__main__":
|
|
142
151
|
unittest.main()
|
package/worker/engine.py
CHANGED
|
@@ -512,7 +512,7 @@ class SingEngine:
|
|
|
512
512
|
return out_sr, self._fit_length(audio, int(round(seg.shape[0] * out_sr / sr)))
|
|
513
513
|
|
|
514
514
|
def convert(self, src: Path, dst: Path, *, pitch: int = 0, index_rate: float = 0.75,
|
|
515
|
-
protect: float = 0.33, rms_mix_rate: float =
|
|
515
|
+
protect: float = 0.33, rms_mix_rate: float = 0.0,
|
|
516
516
|
progress: Optional[Callable[[float, str], None]] = None,
|
|
517
517
|
cancel: Optional[threading.Event] = None) -> dict:
|
|
518
518
|
"""把整段音频切片换声,返回 {sr, chunks, seconds}。"""
|
|
@@ -703,6 +703,7 @@ class SingEngine:
|
|
|
703
703
|
|
|
704
704
|
def song(self, src: Path, work: Path, *, separate: bool = True, mode: str = "full",
|
|
705
705
|
pitch: "int | str" = 0, index_rate: float = 0.75, protect: float = 0.33,
|
|
706
|
+
rms_mix_rate: float = 0.0,
|
|
706
707
|
progress: Optional[Callable[[float, str], None]] = None,
|
|
707
708
|
cancel: Optional[threading.Event] = None) -> dict:
|
|
708
709
|
"""
|
|
@@ -738,7 +739,7 @@ class SingEngine:
|
|
|
738
739
|
report(0.2, "加载模型" if not self.ready else "开始换声")
|
|
739
740
|
conv = work / "vocals_converted.wav"
|
|
740
741
|
info = self.convert(vocal_src, conv, pitch=pitch, index_rate=index_rate,
|
|
741
|
-
protect=protect,
|
|
742
|
+
protect=protect, rms_mix_rate=rms_mix_rate,
|
|
742
743
|
progress=lambda p, m: report(0.2 + 0.6 * p, m), cancel=cancel)
|
|
743
744
|
|
|
744
745
|
if mode == "vocals":
|
|
@@ -791,7 +792,7 @@ class SingEngine:
|
|
|
791
792
|
# -- 选模对比试听 -----------------------------------------------
|
|
792
793
|
|
|
793
794
|
def ab_test(self, test: Path, out_dir: Path, variants: list, *, pitch: int = 0,
|
|
794
|
-
index_rate: float = 0.75, protect: float = 0.33,
|
|
795
|
+
index_rate: float = 0.75, protect: float = 0.33, rms_mix_rate: float = 0.0,
|
|
795
796
|
progress: Optional[Callable[[float, str], None]] = None,
|
|
796
797
|
cancel: Optional[threading.Event] = None) -> dict:
|
|
797
798
|
"""
|
|
@@ -818,6 +819,7 @@ class SingEngine:
|
|
|
818
819
|
report((i + 0.25) / n, f"换声:{label}")
|
|
819
820
|
self.convert(
|
|
820
821
|
test, dst, pitch=pitch, index_rate=index_rate, protect=protect,
|
|
822
|
+
rms_mix_rate=rms_mix_rate,
|
|
821
823
|
progress=lambda p, m, _i=i, _n=n: report((_i + 0.25 + 0.7 * p) / _n, m),
|
|
822
824
|
cancel=cancel,
|
|
823
825
|
)
|
package/worker/server.py
CHANGED
|
@@ -124,6 +124,8 @@ def run_job(jid: str, kind: str, params: dict, cancel: threading.Event) -> dict:
|
|
|
124
124
|
pitch=params.get("pitch", 0),
|
|
125
125
|
index_rate=float(params.get("index_rate", 0.75)),
|
|
126
126
|
protect=float(params.get("protect", 0.33)),
|
|
127
|
+
# 0 = 音量完全跟随原唱(轻唱不会被唱满);老版本传 1.0 = 不跟随
|
|
128
|
+
rms_mix_rate=float(params.get("rms_mix_rate", 0.0)),
|
|
127
129
|
progress=progress,
|
|
128
130
|
cancel=cancel,
|
|
129
131
|
)
|
|
@@ -138,6 +140,7 @@ def run_job(jid: str, kind: str, params: dict, cancel: threading.Event) -> dict:
|
|
|
138
140
|
pitch=int(params.get("pitch", 0)),
|
|
139
141
|
index_rate=float(params.get("index_rate", 0.75)),
|
|
140
142
|
protect=float(params.get("protect", 0.33)),
|
|
143
|
+
rms_mix_rate=float(params.get("rms_mix_rate", 0.0)),
|
|
141
144
|
progress=progress, cancel=cancel,
|
|
142
145
|
)
|
|
143
146
|
|
|
@@ -149,6 +152,7 @@ def run_job(jid: str, kind: str, params: dict, cancel: threading.Event) -> dict:
|
|
|
149
152
|
pitch=int(params.get("pitch", 0)),
|
|
150
153
|
index_rate=float(params.get("index_rate", 0.75)),
|
|
151
154
|
protect=float(params.get("protect", 0.33)),
|
|
155
|
+
rms_mix_rate=float(params.get("rms_mix_rate", 0.0)),
|
|
152
156
|
progress=progress, cancel=cancel,
|
|
153
157
|
)
|
|
154
158
|
|