File size: 1,358 Bytes
5eee449 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | #pragma once
// InflectTTS: two-stage (encoder/decoder AXMODEL) VITS TTS pipeline.
//
// Scope note: the eSpeak text frontend is NOT part of the C++ SDK — the
// caller supplies phoneme token ids (produced by the Python SDK frontend or
// a board-side eSpeak-ng integration; see README). The full duration /
// alignment / expansion / noise / chunking host chain IS implemented here.
#include <cstdint>
#include <string>
#include <vector>
#include "ax_runner.h"
class InflectTTS {
public:
InflectTTS(const std::string& encoder_path, const std::string& decoder_path);
// token_ids: raw phoneme ids (NOT interspersed; blank 0 is inserted here,
// mirroring commons.intersperse with add_blank=true).
// speed in [0.5, 2.0], variation in [0.0, 1.0].
// Returns 24 kHz mono float32 samples in [-1, 1].
std::vector<float> synthesize_tokens(const std::vector<int64_t>& token_ids,
float speed = 1.0f,
float variation = 0.667f,
uint64_t seed = 0);
private:
AxRunner encoder_;
AxRunner decoder_;
// One Tp=512 decoder chunk: z_chunk channel-major [192 * kDecoderTp]
// (zero right-padded) -> wav [kDecoderTp * 256].
std::vector<float> run_decoder_chunk(const std::vector<float>& z_chunk);
};
|