90 lines
2.6 KiB
Python
90 lines
2.6 KiB
Python
|
|
"""CPU-only independent QC; never renders or changes the source video/audio."""
|
||
|
|
|
||
|
|
import argparse
|
||
|
|
import json
|
||
|
|
import os
|
||
|
|
import sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||
|
|
|
||
|
|
|
||
|
|
def main():
|
||
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
||
|
|
for name in (
|
||
|
|
"video",
|
||
|
|
"native-audio",
|
||
|
|
"speech-audio",
|
||
|
|
"speech-report",
|
||
|
|
"reference",
|
||
|
|
"model-root",
|
||
|
|
"output-dir",
|
||
|
|
):
|
||
|
|
parser.add_argument("--" + name, type=Path, required=True)
|
||
|
|
parser.add_argument("--visual-review", type=Path)
|
||
|
|
args = parser.parse_args()
|
||
|
|
os.environ["CUDA_VISIBLE_DEVICES"] = ""
|
||
|
|
os.environ.setdefault("OMP_NUM_THREADS", "2")
|
||
|
|
os.environ.setdefault("OPENBLAS_NUM_THREADS", "2")
|
||
|
|
inputs = {
|
||
|
|
path.resolve()
|
||
|
|
for path in (
|
||
|
|
args.video,
|
||
|
|
args.native_audio,
|
||
|
|
args.speech_audio,
|
||
|
|
args.speech_report,
|
||
|
|
args.reference,
|
||
|
|
)
|
||
|
|
}
|
||
|
|
if args.visual_review:
|
||
|
|
inputs.add(args.visual_review.resolve())
|
||
|
|
if any(
|
||
|
|
(args.output_dir / name).resolve() in inputs
|
||
|
|
for name in (
|
||
|
|
"native-av-acceptance.json",
|
||
|
|
"native-av-error.json",
|
||
|
|
"native-av-evidence.png",
|
||
|
|
"native-av-mouth-timeline.png",
|
||
|
|
)
|
||
|
|
):
|
||
|
|
parser.error("Output directory would overwrite an input")
|
||
|
|
from llm_services.dialogue.native_acceptance import inspect
|
||
|
|
|
||
|
|
try:
|
||
|
|
result = inspect(
|
||
|
|
args.video,
|
||
|
|
args.native_audio,
|
||
|
|
args.speech_audio,
|
||
|
|
args.speech_report,
|
||
|
|
args.reference,
|
||
|
|
args.model_root,
|
||
|
|
args.output_dir,
|
||
|
|
review=args.visual_review,
|
||
|
|
)
|
||
|
|
# 运维命令最外层统一记录未知模型错误为证据不足,绝不把异常转成通过。
|
||
|
|
except Exception as exc: # noqa: BLE001
|
||
|
|
result = {
|
||
|
|
"decision": "indeterminate",
|
||
|
|
"error_type": type(exc).__name__,
|
||
|
|
"message": str(exc),
|
||
|
|
"modifies_source": False,
|
||
|
|
}
|
||
|
|
args.output_dir.mkdir(parents=True, exist_ok=True)
|
||
|
|
(args.output_dir / "native-av-error.json").write_text(
|
||
|
|
json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8"
|
||
|
|
)
|
||
|
|
print(
|
||
|
|
json.dumps(
|
||
|
|
{
|
||
|
|
key: result.get(key)
|
||
|
|
for key in ("decision", "reasons", "error_type", "message")
|
||
|
|
},
|
||
|
|
ensure_ascii=False,
|
||
|
|
)
|
||
|
|
)
|
||
|
|
return 0 if result["decision"] == "pass" else 2
|
||
|
|
|
||
|
|
|
||
|
|
if __name__ == "__main__":
|
||
|
|
raise SystemExit(main())
|