Download code/eval/asr_via_server.py from Modularcomputing/dynamic-accent-duplex: direct link, hf CLI and curl.
- Browser
- Download file 652 Bytes
-
https://huggingface.co/Modularcomputing/dynamic-accent-duplex/resolve/2ea57e9d07394349d876eb45c9027a1a75e546d9/code/eval/asr_via_server.py
- Command line
-
hf download hf://Modularcomputing/dynamic-accent-duplex@2ea57e9d07394349d876eb45c9027a1a75e546d9/code/eval/asr_via_server.py
-
curl -L -o asr_via_server.py https://huggingface.co/Modularcomputing/dynamic-accent-duplex/resolve/2ea57e9d07394349d876eb45c9027a1a75e546d9/code/eval/asr_via_server.py
652 Bytes
| """Re-run the ASR eval through the live ASR server (e.g. CTC_1B + Latin-script mask): python asr_via_server.py <tag>""" | |
| import json, sys, time, httpx, soundfile as sf, numpy as np | |
| D = "/scratch/duplex/asr_eval"; c = httpx.Client(timeout=30); out = open(f"{D}/hyp_{sys.argv[1]}.jsonl", "w") | |
| for l in open(f"{D}/list.jsonl"): | |
| r = json.loads(l); y = sf.read(r["wav"], dtype="float32")[0] | |
| t = time.perf_counter(); h = c.post("http://127.0.0.1:8002/asr", content=y.tobytes()).json(); dt = time.perf_counter() - t | |
| out.write(json.dumps(dict(id=r["id"], hyp=h["text"], lat=round(dt, 4), dur=r["dur"]), ensure_ascii=False) + "\n") | |
| print("VIA_DONE") | |