Download scripts/fp32_same.py from matthiastl/gepard-onnx: direct link, hf CLI and curl.
- Browser
- Download file 1.28 kB
-
https://huggingface.co/matthiastl/gepard-onnx/resolve/main/scripts/fp32_same.py
- Command line
-
hf download hf://matthiastl/gepard-onnx/scripts/fp32_same.py
-
curl -L -o fp32_same.py https://huggingface.co/matthiastl/gepard-onnx/resolve/main/scripts/fp32_same.py
1.28 kB
| """Does the full-precision port say exactly what the original says? Same seeds and voices, frames compared.""" | |
| import sys, json; from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| import numpy as np, port as P, port2 | |
| p = port2.Port2(decoder="decoder.onnx", threads=4); ids = json.load(open(P.ROOT / "data" / "ids100.json")); enc = P.session(P.ROOT / "export" / "codec_encoder.onnx", 4) | |
| pre = [p.prefix(enc.run(None, {"audio": np.load(P.ROOT / f"runs/clips/{k}.npz")["wav"][None]})[0][0]) for k in range(3)] | |
| same = diff = 0; run = 0; first = [] | |
| for base in (8000, 9000, 10000): | |
| for i, s in enumerate(ids): | |
| f, a = p.speak(s, base + i, prefix=pre[i % 3]); r = np.load(P.ROOT / f"runs/words3-ref-{base}/{i:03d}.npy"); ok = f.shape == r.shape and bool((f == r).all()); same += ok; diff += not ok; run += len(f) >= 600 | |
| if not ok: n = min(len(f), len(r)); first.append((base + i, int(np.argmax((f[:n] != r[:n]).any(1)) if (f[:n] != r[:n]).any() else n), len(f), len(r))) | |
| print(base, "identical so far", same, "different", diff, flush=True) | |
| print("fp32 port vs original, 300 utterances with voices: identical", same, "different", diff, "| port to 600 frames:", run, "| first differences (seed, frame, port length, original length):", first[:8]) | |