Download models/zipvoice/cpp/src/vocoder.hpp from AXERA-TECH/Voice_Assistant.AXERA: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/AXERA-TECH/Voice_Assistant.AXERA/resolve/main/models/zipvoice/cpp/src/vocoder.hpp
- Command line
-
hf download hf://AXERA-TECH/Voice_Assistant.AXERA/models/zipvoice/cpp/src/vocoder.hpp
-
curl -L -o vocoder.hpp https://huggingface.co/AXERA-TECH/Voice_Assistant.AXERA/resolve/main/models/zipvoice/cpp/src/vocoder.hpp
1.82 kB
| /************************************************************************************************** | |
| * ZipVoice AXERA C++ Port | |
| * | |
| * Vocoder: mel features → audio via vocos_full.axmodel + IRFFT + overlap-add. | |
| **************************************************************************************************/ | |
| class Vocoder { | |
| public: | |
| struct Config { | |
| std::string model_path; | |
| int n_fft = 1024; | |
| int hop_length = 256; | |
| int win_length = 1024; | |
| int n_mels = 100; | |
| int sample_rate = 24000; | |
| }; | |
| Vocoder(); | |
| ~Vocoder(); | |
| /** | |
| * Initialize: load vocos_full.axmodel and pre-compute IRFFT basis. | |
| */ | |
| int Init(const Config& cfg); | |
| /** | |
| * Decode mel features to audio waveform. | |
| * @param mel Mel features [T, n_mels] (flat, row-major) | |
| * @param T Number of mel frames | |
| * @param feat_scale Feature scaling factor to undo (Python: features/feat_scale before vocoder) | |
| * @param audio Output audio samples (24kHz float32) | |
| */ | |
| int Decode(const std::vector<float>& mel, int T, float feat_scale, std::vector<float>& audio); | |
| bool HasInit() const { return m_has_init; } | |
| private: | |
| Config m_cfg; | |
| bool m_has_init; | |
| std::unique_ptr<EngineWrapper> m_session; | |
| // kissfft configs (shared forward/inverse twiddles) | |
| kiss_fft_state* m_fft_cfg = nullptr; | |
| kiss_fft_state* m_ifft_cfg = nullptr; | |
| // Hann window | |
| std::vector<float> m_window; | |
| // Window squared for envelope normalization | |
| std::vector<float> m_window_sq; | |
| int m_n_freqs; | |
| void BuildWindow(); | |
| static void Fft(std::vector<float>& real, std::vector<float>& imag, bool inverse); | |
| }; | |