dynamic-accent-duplex / code /eval /asr_via_server.py
UncleanCode's picture
Dynamic Accent Duplex 0.2.0: Dynamic ASR real as default ASR (omniASR fallback)
ac573f1 verified
Raw History Blame
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")