inflect_micro_v2 / cpp /src /inflect_tts.h
inoryQwQ's picture
三芯片合并:AX620E/AX637 升级 encoder+decoder 全 NPU,新增新一代 SDK;AX650 保持老 SDK
5eee449 verified
Raw
History Blame Contribute Delete
1.36 kB
#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);
};