Fix opening filler with bare Instrumental and dual-gate QC.
selftest / selftest (push) Canceled after 0s
selftest / selftest (push) Canceled after 0s
ACE-Step no-vocal condition is the exact [Instrumental] marker; colon prose in the lyrics channel induced wordless filler. Recheck now ASRs full vocals and pairs filler ratio with demucs energy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+16
-11
@@ -23,19 +23,23 @@ def main(job):
|
||||
bars = int(job.get("intro_bars") or 8)
|
||||
lang = job.get("lang") or "zh"
|
||||
intro_sec = bars * 60.0 / bpm * 4.0
|
||||
# 多取 0.5s 余量
|
||||
take = min(intro_sec + 0.5, 60.0)
|
||||
|
||||
y, sr, ch = q._load_audio(path)
|
||||
n = int(take * sr)
|
||||
head = y[:max(1, n)]
|
||||
a = q.asr(head, sr, lang)
|
||||
# 与全量 qc 同口径:对整段 vocals 做 ASR,再按时间窗统计。
|
||||
# 只切前奏短窗喂 Whisper 会严重少计衬词(实测只吐 1 个「嗯」却 PASS)。
|
||||
v, vsr = q.vocals_of(path, job.get("cache_dir"))
|
||||
a = q.asr(v, vsr, lang)
|
||||
segs = a.get("segments") or []
|
||||
# 时间戳相对 clip 起点,整段都在前奏窗内
|
||||
stats = q.intro_filler_stats(segs, intro_sec + 1.0, lang)
|
||||
stats = q.intro_filler_stats(
|
||||
segs, intro_sec, lang, voc=v, vsr=vsr)
|
||||
hard = q.HARD
|
||||
fail = (stats["intro_filler_n"] >= hard["intro_filler_min_chars"]
|
||||
and stats["intro_filler_ratio"] >= hard["intro_filler_ratio"])
|
||||
ivr = float(stats.get("intro_voc_rms") or 0)
|
||||
ifn = int(stats["intro_filler_n"])
|
||||
ifr = float(stats["intro_filler_ratio"])
|
||||
# 有人声能量时降低字数门槛:短窗幻觉「单个嗯」也要拦
|
||||
eff_min = hard["intro_filler_min_chars"]
|
||||
if ivr >= hard["intro_voc_rms_min"]:
|
||||
eff_min = min(eff_min, 2)
|
||||
fail = (ifn >= eff_min and ifr >= hard["intro_filler_ratio"]
|
||||
and ivr >= hard["intro_voc_rms_min"])
|
||||
# 前 2s 真唱字(content words)也算开曲违规
|
||||
early = 0
|
||||
for s in segs:
|
||||
@@ -50,6 +54,7 @@ def main(job):
|
||||
intro_sec=round(intro_sec, 2),
|
||||
early_content=early,
|
||||
asr_head=(a.get("text") or "")[:160],
|
||||
eff_min=eff_min,
|
||||
**stats,
|
||||
)
|
||||
|
||||
|
||||
+34
-11
@@ -86,6 +86,9 @@ HARD = dict(
|
||||
# 阈值刻意偏严:用户要求「不能出开曲衬词」;Whisper 偶发单字可被 min 挡住。
|
||||
intro_filler_min_chars=6, # 前奏窗内至少累计这么多衬词字/词才判
|
||||
intro_filler_ratio=0.55, # 衬词占前奏窗 ASR 单元比例
|
||||
# Whisper 常在纯器乐上幻觉「嗯/啊」;必须再看 demucs vocals 能量。
|
||||
# 前奏窗 vocals RMS 低于此阈值 → 视为幻觉,不因 ASR 衬词 FAIL。
|
||||
intro_voc_rms_min=0.008,
|
||||
# ---- 歌词感知分类阈值(见文件头坑位 6/7)----
|
||||
# lyric_hit >= 0.34 -> 真唱;instr_hit >= 0.40 -> 生成指令泄漏。
|
||||
# 这两个数是在 8 首已认可老歌 + 本批 8 首上交叉验证出来的:
|
||||
@@ -706,11 +709,14 @@ def filler_ratio(asr_text, lang="zh"):
|
||||
return n / float(len(chars))
|
||||
|
||||
|
||||
def intro_filler_stats(segs, intro_sec, lang="zh"):
|
||||
def intro_filler_stats(segs, intro_sec, lang="zh", voc=None, vsr=None):
|
||||
"""前奏时间窗内的衬词统计(硬门用)。
|
||||
|
||||
vocal_onset / head_chars 只看「真唱实义词」,会故意丢掉 嗯/呀/ooh,
|
||||
导致开曲衬词满天飞仍 PASS。这里单独扫前奏窗 ASR。
|
||||
|
||||
若传入 demucs vocals(voc/vsr),同时算前奏窗 RMS:Whisper 在纯器乐上
|
||||
常幻觉衬词,能量门用来区分「真有无词人声」与「ASR 幻觉」。
|
||||
"""
|
||||
total = 0
|
||||
fill = 0
|
||||
@@ -732,9 +738,15 @@ def intro_filler_stats(segs, intro_sec, lang="zh"):
|
||||
"".join(f)[:24] if not _is_en(lang)
|
||||
else " ".join(f)[:24]))
|
||||
ratio = (fill / float(total)) if total else 0.0
|
||||
intro_voc_rms = 0.0
|
||||
if voc is not None and vsr:
|
||||
n = int(min(float(intro_sec), len(voc) / float(vsr)) * float(vsr))
|
||||
if n > 0:
|
||||
intro_voc_rms = _rms(voc[:n])
|
||||
return dict(intro_filler_n=fill, intro_asr_n=total,
|
||||
intro_filler_ratio=round(ratio, 4),
|
||||
intro_filler_samples=samples[:4])
|
||||
intro_filler_samples=samples[:4],
|
||||
intro_voc_rms=round(intro_voc_rms, 6))
|
||||
|
||||
|
||||
def coverage(asr_text, lyrics, lang="zh"):
|
||||
@@ -933,9 +945,10 @@ def measure(path, expect=None, cache_dir=None, with_asr=True):
|
||||
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 \
|
||||
ifest = intro_filler_stats(segs, intro_sec, lang, voc=v, vsr=vsr) \
|
||||
if with_asr else \
|
||||
dict(intro_filler_n=0, intro_asr_n=0, intro_filler_ratio=0.0,
|
||||
intro_filler_samples=[])
|
||||
intro_filler_samples=[], intro_voc_rms=0.0)
|
||||
|
||||
# ---- 风格分类:只看混音轨,不掺 demucs(见 qc_style 文件头坑位 4)
|
||||
svec, sraw = qc_style.features(path, expect_bpm=expect.get("bpm"))
|
||||
@@ -967,6 +980,7 @@ def measure(path, expect=None, cache_dir=None, with_asr=True):
|
||||
intro_asr_n=ifest["intro_asr_n"],
|
||||
intro_filler_ratio=ifest["intro_filler_ratio"],
|
||||
intro_filler_samples=ifest["intro_filler_samples"],
|
||||
intro_voc_rms=ifest.get("intro_voc_rms", 0.0),
|
||||
asr_head=txt[:120],
|
||||
voice_self=round(float(e_self), 4),
|
||||
flatness=round(sraw.get("flatness", 0.0), 4),
|
||||
@@ -1069,18 +1083,27 @@ def judge(rows, baseline):
|
||||
why.append("前 2s 就已唱出 %d 个%s,疑似纯人声/spoken 开头"
|
||||
% (r["head_chars_0_2"], unit))
|
||||
# ---- 铁律一-b:禁止开曲衬词(嗯/呀/ooh…)
|
||||
# vocal_onset 只看真唱,会漏掉衬词;此处扫前奏窗 ASR。
|
||||
# ASR 衬词 + demucs vocals 能量双门:纯器乐静音上的幻觉不 FAIL。
|
||||
# demucs 常有 ~0.09 器乐泄漏,能量门挡的是近零 RMS;有能量时
|
||||
# 字数门槛降到 2,避免「满屏嗯」却因短窗少计而漏网。
|
||||
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"]:
|
||||
ivr = float(r.get("intro_voc_rms") or 0.0)
|
||||
eff_min = HARD["intro_filler_min_chars"]
|
||||
if ivr >= HARD["intro_voc_rms_min"]:
|
||||
eff_min = min(eff_min, 2)
|
||||
if ifn >= eff_min and ifr >= HARD["intro_filler_ratio"] and \
|
||||
ivr >= HARD["intro_voc_rms_min"]:
|
||||
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 ""))
|
||||
why.append(
|
||||
"开曲衬词 %d 单元占比 %.0f%% 且前奏人声能量 %.4f"
|
||||
"(≥%d 且 ≥%.0f%% 且 RMS≥%.3f)%s"
|
||||
% (ifn, ifr * 100, ivr, eff_min,
|
||||
HARD["intro_filler_ratio"] * 100,
|
||||
HARD["intro_voc_rms_min"],
|
||||
(":" + tip) if tip else ""))
|
||||
# ---- 铁律二:8 小节器乐前奏(完整 8 小节,不是 55%)
|
||||
# 原来判的是 vocal_onset < want * 0.55,等于"第 4~5 小节进 sang
|
||||
# 也算过",把铁律降级成建议。现在按完整 8 小节判,只留
|
||||
|
||||
Reference in New Issue
Block a user