"""RULE-3: the original with voices, 3 seed sets x 100 sentences.""" 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() pre = [torch.from_numpy(np.load(R.ROOT / f"runs/clips/{k}.npz")["prefix"])[None] for k in range(3)] for base in (8000, 9000, 10000): out = R.ROOT / "runs" / f"words3-ref-{base}"; out.mkdir(parents=True, exist_ok=True) for i, t in enumerate(texts.ALL): if (out / f"{i:03d}.npy").exists(): continue codes = r.generate(t, seed=base + i, max_frames=600, prefix=pre[i % 3]) 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)