Fix opening filler via lean tags and intro QC gate.
selftest / selftest (push) Canceled after 0s

Stop naming filler syllables in tags (they conditioned the model); default prefer_lean_tags; hard-fail intro_filler in QC; add plugins/ hook bus as thin microkernel extension point.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
swl
2026-10-10 12:49:25 +08:00
co-authored by Cursor
parent 0ab8d8ad4d
commit b1afe68f3c
20 changed files with 426 additions and 84 deletions
+64 -3
View File
@@ -81,6 +81,11 @@ HARD = dict(
# (Whisper 段落起点最多会早报 0.5s 左右),不是用来放水进水点的。
intro_onset_rel=1.0,
onset_grace=1.2, # 秒,ASR 时间戳容差
# ---- 开曲衬词硬门(vocal_onset 只看真唱,会漏掉 嗯/呀/ooh)----
# 前奏窗内 ASR 汉字/英文词若绝大多数是衬词,或衬词绝对量过大 → FAIL。
# 阈值刻意偏严:用户要求「不能出开曲衬词」;Whisper 偶发单字可被 min 挡住。
intro_filler_min_chars=6, # 前奏窗内至少累计这么多衬词字/词才判
intro_filler_ratio=0.55, # 衬词占前奏窗 ASR 单元比例
# ---- 歌词感知分类阈值(见文件头坑位 6/7)----
# lyric_hit >= 0.34 -> 真唱;instr_hit >= 0.40 -> 生成指令泄漏。
# 这两个数是在 8 首已认可老歌 + 本批 8 首上交叉验证出来的:
@@ -368,7 +373,7 @@ into over under again very so no yes
# 口径必须和歌词召回分开:mm / yeah / okay 这类在歌里是 legit 的
# 律动衬词,但绝不能算成"真的唱出内容了"。
EN_FILLER = frozenset("""
oh ah uh um mm hmm mhm okay ok yeah yep
oh ah uh um mm hmm mhm mmm ooo ooh woo yeah yep yo ya la na da hey
""".split())
@@ -422,7 +427,8 @@ def asr(wav, sr, lang="zh"):
# 语气词/无意义哼唱。Whisper 对纯伴奏段落会吐出成百上千个"嗯""啊",
# 实测 pop 前奏被吐 112 个"嗯"、hiphop 前奏 223 个"啊",去重后只有 1 个
# 字符。这些既不能算歌词,也不能算人声进入点。
FILLER = set("嗯啊哦噢喔呃哎唉嘿咦哟唔唷哼嘻嘿")
# 开曲衬词硬门会单独统计前奏窗内的这些字(含恩/昂/呀/咿)。
FILLER = set("嗯啊哦噢喔呃哎唉嘿咦哟唔唷哼嘻嘿恩昂呀咿喔吶呐")
def real_cjk(text):
@@ -700,6 +706,37 @@ def filler_ratio(asr_text, lang="zh"):
return n / float(len(chars))
def intro_filler_stats(segs, intro_sec, lang="zh"):
"""前奏时间窗内的衬词统计(硬门用)。
vocal_onset / head_chars 只看「真唱实义词」,会故意丢掉 嗯/呀/ooh,
导致开曲衬词满天飞仍 PASS。这里单独扫前奏窗 ASR。
"""
total = 0
fill = 0
samples = []
for s in segs or []:
if float(s.get("t0", 0)) >= float(intro_sec):
continue
t = s.get("text") or ""
if _is_en(lang):
units = _en_words(_strip_tags(t))
f = [w for w in units if w in EN_FILLER]
else:
units = list(cjk(t))
f = [c for c in units if c in FILLER]
total += len(units)
fill += len(f)
if f:
samples.append((round(float(s.get("t0", 0)), 2),
"".join(f)[:24] if not _is_en(lang)
else " ".join(f)[:24]))
ratio = (fill / float(total)) if total else 0.0
return dict(intro_filler_n=fill, intro_asr_n=total,
intro_filler_ratio=round(ratio, 4),
intro_filler_samples=samples[:4])
def coverage(asr_text, lyrics, lang="zh"):
"""ASR 召回率:ASR 里命中的歌词单元 / 歌词正文单元。
@@ -890,8 +927,15 @@ def measure(path, expect=None, cache_dir=None, with_asr=True):
if half > vsr else 0.0
cov = coverage(txt, lyr, lang) if with_asr else 0.0
# 衬词占比:弱参考,不单独导致 FAIL(与 style_fam 同级)
# 全曲衬词占比:弱参考;前奏窗衬词:硬门(见 judge)
fill_r = filler_ratio(txt, lang) if with_asr else 0.0
intro_sec = 8.0
if expect.get("bpm") and expect.get("intro_bars"):
intro_sec = (float(expect["intro_bars"]) * 60.0
/ float(expect["bpm"]) * 4.0)
ifest = intro_filler_stats(segs, intro_sec, lang) if with_asr else \
dict(intro_filler_n=0, intro_asr_n=0, intro_filler_ratio=0.0,
intro_filler_samples=[])
# ---- 风格分类:只看混音轨,不掺 demucs(见 qc_style 文件头坑位 4)
svec, sraw = qc_style.features(path, expect_bpm=expect.get("bpm"))
@@ -919,6 +963,10 @@ def measure(path, expect=None, cache_dir=None, with_asr=True):
f0_drift_st=round(f0_drift_st, 2),
asr_chars=len(tokens(txt, lang)), asr_segs=len(segs),
coverage=round(cov, 4), filler_ratio=round(fill_r, 4),
intro_filler_n=ifest["intro_filler_n"],
intro_asr_n=ifest["intro_asr_n"],
intro_filler_ratio=ifest["intro_filler_ratio"],
intro_filler_samples=ifest["intro_filler_samples"],
asr_head=txt[:120],
voice_self=round(float(e_self), 4),
flatness=round(sraw.get("flatness", 0.0), 4),
@@ -1020,6 +1068,19 @@ def judge(rows, baseline):
unit = "词" if _is_en(r.get("lang", e.get("lang"))) else "汉字"
why.append("前 2s 就已唱出 %d 个%s,疑似纯人声/spoken 开头"
% (r["head_chars_0_2"], unit))
# ---- 铁律一-b:禁止开曲衬词(嗯/呀/ooh…)
# vocal_onset 只看真唱,会漏掉衬词;此处扫前奏窗 ASR。
ifn = int(r.get("intro_filler_n") or 0)
ifr = float(r.get("intro_filler_ratio") or 0.0)
if ifn >= HARD["intro_filler_min_chars"] and \
ifr >= HARD["intro_filler_ratio"]:
samp = r.get("intro_filler_samples") or []
tip = ("; ".join("%ss:%s" % (a, b) for a, b in samp[:2])
if samp else "")
why.append("开曲衬词 %d 单元占比 %.0f%%(≥%d 且 ≥%.0f%%)%s"
% (ifn, ifr * 100, HARD["intro_filler_min_chars"],
HARD["intro_filler_ratio"] * 100,
(":" + tip) if tip else ""))
# ---- 铁律二:8 小节器乐前奏(完整 8 小节,不是 55%)
# 原来判的是 vocal_onset < want * 0.55,等于"第 4~5 小节进 sang
# 也算过",把铁律降级成建议。现在按完整 8 小节判,只留