Files
swlandCursor 6d79ab93a2
selftest / selftest (push) Canceled after 0s
Add align/recheck/compare, plugins, and refresh Agent docs.
Wire deliver_report/listen_pack/retry hooks; gen --auto-retry and intro light check; make AGENTS_MIN the up-to-date agent entry with full command map.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-10 13:03:44 +08:00

85 lines
3.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -*- coding: utf-8 -*-
"""生歌结束后按 AGENTS_MIN 模板写 report.md。"""
import json
import os
from ..hooks import bus
def _write_report(rundir, man, qc=None, intro=None):
if not rundir:
return
rows = []
verd = "-"
if qc:
rows = [r for r in (qc.get("rows") or []) if r.get("group") != "baseline"]
vs = qc.get("verdicts") or []
if vs:
verd = vs[0].get("verdict") or "-"
r0 = rows[0] if rows else {}
audio = "-"
for r in man.get("results") or []:
files = r.get("files") or []
if files:
audio = files[0]
break
intro_line = "-"
if intro:
intro_line = "ok=%s n=%s ratio=%s" % (
intro.get("ok"), intro.get("intro_filler_n"),
intro.get("intro_filler_ratio"))
elif r0:
intro_line = "n=%s ratio=%s" % (
r0.get("intro_filler_n"), r0.get("intro_filler_ratio"))
body = "\n".join([
"## 生歌报告",
"- 结论:%s" % (verd if verd != "-" else (man.get("qc_verdict") or "—")),
"- 歌名 / 风格 / BPM / 设定时长:%s / %s / %s / %s" % (
man.get("title") or "—", man.get("style") or "—",
man.get("bpm") or "—", man.get("duration") or "—"),
"- run_id:%s" % (man.get("run_id") or os.path.basename(rundir)),
"- 音频路径:%s" % audio,
"- 歌词:见本目录 lyrics.txt;密度见 manifest.density",
"- QC:verdict=%s;voice_nn=%s sim=%s;开曲衬词 %s;filler_ratio=%s" % (
verd, r0.get("voice_nn") or "—", r0.get("voice_nn_sim") or "—",
intro_line, r0.get("filler_ratio") if r0 else "—"),
"- 弱参考:style_fam=%s style_conf=%s" % (
r0.get("style_fam") or "—", r0.get("style_conf") or "—"),
"- 模型/采样:见 manifest.model / sampler / encode",
"- 种子:%s" % (
", ".join(str(x.get("seed")) for x in (man.get("results") or [])
if x.get("seed") is not None) or "—"),
"- 建议:先听 listen/ 前奏与副歌片段;FAIL 则改词或换 seed 重 gen",
"",
])
path = os.path.join(rundir, "report.md")
with open(path, "w", encoding="utf-8") as f:
f.write(body)
return path
@bus.on("after_gen")
def _on_gen(run_dir=None, manifest=None, **_kw):
if not run_dir or not manifest:
return None
path = _write_report(run_dir, manifest)
return dict(report=path) if path else None
@bus.on("after_qc")
def _on_qc(run_dir=None, report=None, **_kw):
if not run_dir:
return None
man = {}
mp = os.path.join(run_dir, "manifest.json")
if os.path.isfile(mp):
with open(mp, encoding="utf-8") as f:
man = json.load(f)
intro = None
ip = os.path.join(run_dir, "intro_check.json")
if os.path.isfile(ip):
with open(ip, encoding="utf-8") as f:
intro = json.load(f)
path = _write_report(run_dir, man, qc=report, intro=intro)
return dict(report=path) if path else None