File size: 652 Bytes
ac573f1
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
"""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")