52 lines
1.8 KiB
Python
52 lines
1.8 KiB
Python
|
|
"""只读双人试拍检查:python scripts/inspect_native_turns.py candidate.json --model-root DIR --output NEW.json"""
|
|||
|
|
|
|||
|
|
import argparse
|
|||
|
|
import json
|
|||
|
|
import sys
|
|||
|
|
from pathlib import Path
|
|||
|
|
|
|||
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
|||
|
|
|
|||
|
|
|
|||
|
|
def main():
|
|||
|
|
from llm_services.dialogue.native_turns import POLICY, inspect_candidate
|
|||
|
|
|
|||
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|||
|
|
parser.add_argument("candidate", type=Path)
|
|||
|
|
parser.add_argument("--model-root", required=True, type=Path)
|
|||
|
|
parser.add_argument("--output", required=True, type=Path)
|
|||
|
|
args = parser.parse_args()
|
|||
|
|
if args.output.exists():
|
|||
|
|
parser.error("Output must be a new file")
|
|||
|
|
try:
|
|||
|
|
spec = json.loads(args.candidate.read_bytes())
|
|||
|
|
for key in (
|
|||
|
|
"video",
|
|||
|
|
"native_audio",
|
|||
|
|
"speech_audio",
|
|||
|
|
"speech_report",
|
|||
|
|
"first_frame",
|
|||
|
|
"visual_review",
|
|||
|
|
):
|
|||
|
|
if spec.get(key):
|
|||
|
|
spec[key] = args.candidate.parent / spec[key]
|
|||
|
|
for row in spec["speakers"]:
|
|||
|
|
for key in ("face", "voice"):
|
|||
|
|
row[key] = args.candidate.parent / row[key]
|
|||
|
|
report = inspect_candidate(spec, args.model_root)
|
|||
|
|
except Exception as exc: # noqa: BLE001 — record unavailable measurements in the offline report.
|
|||
|
|
report = {
|
|||
|
|
"policy": POLICY,
|
|||
|
|
"decision": "indeterminate",
|
|||
|
|
"reason": str(exc),
|
|||
|
|
"error_type": type(exc).__name__,
|
|||
|
|
}
|
|||
|
|
with args.output.open("x", encoding="utf-8") as stream:
|
|||
|
|
json.dump(report, stream, ensure_ascii=False, allow_nan=False, indent=2)
|
|||
|
|
print(report["decision"], args.output)
|
|||
|
|
return 0 if report["decision"] == "pass" else 2
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
raise SystemExit(main())
|