File size: 869 Bytes
f730521 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | """Pairs for eval/eval_wer.py from a benchmark arm: each reply's audio and the words it was meant to say
(the lead-in, if there was one, and the answer).
python -m tools.wer_pairs eval/results/bba3/lead_gate/judge eval/results/wer_lead_gate/pairs
"""
import json
import shutil
import sys
from pathlib import Path
src, dst = Path(sys.argv[1]), Path(sys.argv[2])
dst.mkdir(parents=True, exist_ok=True)
n = 0
for f in sorted(src.glob("q_*.json")):
r = json.loads(f.read_text(encoding="utf-8"))
done = [e for e in r["events"] if e["type"] == "reply.done" and e["reason"] == "done"]
wav = f.with_suffix(".wav")
if not done or not wav.exists():
continue
shutil.copy(wav, dst / wav.name)
(dst / f"{f.stem}.txt").write_text(((done[-1].get("lead_text") or "") + " " + done[-1]["text"]).strip(), encoding="utf-8")
n += 1
print(n, "pairs")
|