// Source-filter synthesizer of the Hindi tiny-voca TTS: a C++ port of tiny_voca.model.SourceFilter.forward and // pulse_train (tts_hi/tiny_voca/model.py). Plain C++, no ggml: the network only predicts the per-frame heads. #pragma once #include #include struct SynthConfig { int sample_rate = 24000, hop = 256; int synth_fft = 512, synth_hop = 128, noise_fft = 256, noise_hop = 64; int cep_causal = 80, cep_anti = 16, noise_cep = 32; float harmonic_limit = 0.47f; std::vector causal_lifter, anti_lifter, noise_lifter; }; // harmonic: [T][cep_causal + cep_anti + hop/synth_hop] row-major, noise_head: [T][noise_cep + hop/noise_hop], // f0: [T] Hz, noise: T*hop white-noise samples. Returns T*hop samples. std::vector synthesize_wave(const SynthConfig& c, const float* harmonic, const float* noise_head, const float* f0, int T, const float* noise); // Vocos ISTFTHead after its Linear: head [frames][n_fft + 2] = (log magnitude, phase) per bin -> torch.istft // (center=True, periodic Hann, window = n_fft). Returns hop * (frames - 1) samples. std::vector vocos_istft(const float* head, int frames, int n_fft, int hop); // Band-limited pulse train (unit power), as model.pulse_train. std::vector pulse_train(const float* f0, int T, int sample_rate, int hop, double limit);