Download tools/wer_pairs.py from RightNowAI/duplex-v0: direct link, hf CLI and curl.
- Browser
- Download file 869 Bytes
-
https://huggingface.co/RightNowAI/duplex-v0/resolve/main/tools/wer_pairs.py
- Command line
-
hf download hf://RightNowAI/duplex-v0/tools/wer_pairs.py
-
curl -L -o wer_pairs.py https://huggingface.co/RightNowAI/duplex-v0/resolve/main/tools/wer_pairs.py
869 Bytes
| """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") | |