"""Opus features (20 per 10 ms frame) and copy synthesis with PiVo's FARGAN vocoder. fargan_demo -features (xiph/opus bafd40d, BSD-3) writes 20 floats per frame: 18 cepstra, pitch (log2(256/period) - 1.5) and pitch correlation. """ import subprocess, tempfile from pathlib import Path import numpy as np import os ROOT = Path(__file__).resolve().parent.parent # repository root DUMP = Path(os.environ.get("FARGAN_DEMO", ROOT / "bin" / "fargan_demo")) # see docs/HOW-WE-TRAINED.md, section 0 HOP = 160 DELAY = 80 # native extractor delay: frame k describes [160k-80, 160k+80) def extract(wave16k): """wave16k float32 em [-1,1] a 16 kHz -> (quadros, 20) float32.""" pcm = (np.clip(wave16k, -1, 1) * 32767).round().astype("