Download scripts/words_ref.py from matthiastl/gepard-onnx: direct link, hf CLI and curl.
- Browser
- Download file 828 Bytes
-
https://huggingface.co/matthiastl/gepard-onnx/resolve/main/scripts/words_ref.py
- Command line
-
hf download hf://matthiastl/gepard-onnx/scripts/words_ref.py
-
curl -L -o words_ref.py https://huggingface.co/matthiastl/gepard-onnx/resolve/main/scripts/words_ref.py
828 Bytes
| import sys; from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).parent)) | |
| import numpy as np, torch, soundfile as sf, codec, reference as R, texts | |
| half = np.array([4, 3, 3, 3] * 8, np.float32); r, c = R.Reference(), codec.load() | |
| for base in map(int, sys.argv[1:]): | |
| out = R.ROOT / "runs" / f"words-ref-{base}"; out.mkdir(parents=True, exist_ok=True); n = 0 | |
| for i, t in enumerate(texts.ALL): | |
| if (out / f"{i:03d}.wav").exists(): continue | |
| codes = r.generate(t, seed=base + i, max_frames=600) | |
| with torch.no_grad(): a, _ = c.decode_audio(inputs=torch.from_numpy((codes.astype(np.float32) - half) / half).T[None], input_len=torch.tensor([len(codes)])) | |
| sf.write(out / f"{i:03d}.wav", a[0].numpy(), 22050); np.save(out / f"{i:03d}.npy", codes) | |
| print("ref", base, "done", flush=True) | |