Download python/test_frontend_parity.py from KaleComputer/kale-tts-1-tiny: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/python/test_frontend_parity.py
- Command line
-
hf download hf://KaleComputer/kale-tts-1-tiny/python/test_frontend_parity.py
-
curl -L -o test_frontend_parity.py https://huggingface.co/KaleComputer/kale-tts-1-tiny/resolve/main/python/test_frontend_parity.py
1.34 kB
| """QuickJS front end (no node) vs the node helper (= the JS API's front end): identical sentences + IPA on the bench texts + rule-heavy lines.""" | |
| import json, sys, time | |
| from pathlib import Path | |
| HERE = Path(__file__).resolve().parent; sys.path.insert(0, str(HERE)) | |
| from kale_tts import FrontEnd, QuickJSFrontEnd | |
| texts = [json.loads(l)["text"] for l in open(HERE.parent / "frontend/frontend-test.jsonl")] + [ | |
| "On 3 May 2026 at 9:30, 12 kids saw 1,500 m of lava for $4.50.", "Dr. Smith read the README at 10:15pm; useEffect and WebGPU in iOS 18.", "It's 21°C, 3.5% and 1/2 a cup.", "Install Node.js and Transformers.js, then run main.js.", "The CLI and two CLIs use JS and kokoro-js with onnxruntime-web."] | |
| t = time.perf_counter(); q = QuickJSFrontEnd(); init = time.perf_counter() - t; n = FrontEnd() | |
| t = time.perf_counter(); a = [q(x) for x in texts]; tq = time.perf_counter() - t | |
| t = time.perf_counter(); b = [[{"text": s["text"], "ipa": s["ipa"]} for s in n(x)] for x in texts]; tn = time.perf_counter() - t | |
| same = sum(x == y for x, y in zip(a, b)) | |
| print(json.dumps(dict(texts=len(texts), identical=same, quickjs_init_s=round(init, 2), quickjs_ms_per_text=round(1000 * tq / len(texts), 2), node_ms_per_text=round(1000 * tn / len(texts), 2)))) | |
| for x, y, t in zip(a, b, texts): | |
| if x != y: print("DIFF", t, x, y); break | |
| n.close() | |