Clone Encoder Runner#
-
class CloneEncoderRunner#
Runner for the Qwen3-TTS voice-clone reference encoders (Base checkpoints)
Wraps two engines exported from the Base checkpoint:
speaker_encoder.engine: 24kHz waveform [1, T] (dynamic) -> x-vector [1, talkerHidden]. Mel extraction (STFT 1024/256, slaney mel-128, log) is folded into the graph as conv-DFT, so the input is raw PCM.
speech_tokenizer_encoder.engine: 24kHz waveform [1, bucketLen] (static bucket, zero-padded) -> RVQ codes [bucketFrames, numQuantizers]. The encoder is causal, so padding does not affect earlier frames; callers take the first floor(numSamples / downsampleRate) complete frames.
Follows the Code2WavRunner pattern (plain TRT engines, no LLM pipeline).
Public Functions
-
CloneEncoderRunner(std::string const &engineDir, cudaStream_t stream)#
- Parameters:
engineDir – Directory containing speaker_encoder.engine and (optionally) speech_tokenizer_encoder.engine. The tokenizer engine may be absent if only x-vector cloning is needed.
-
~CloneEncoderRunner() noexcept = default#
- bool extractSpeakerEmbedding( )#
Extract the speaker x-vector from a 24kHz mono waveform.
- Parameters:
wav24k – Host PCM float32 in [-1, 1] at 24kHz
xvecOut – GPU tensor [hiddenDim] FP16, written in place (must be preallocated)
- bool encodeReferenceCodes(
- std::vector<float> const &wav24k,
- int32_t &numFrames,
- cudaStream_t stream
Encode reference codec codes from a 24kHz mono waveform. Codes stay on device — consume them via refCodesDevice() (e.g. the codec-embedding sum kernel reads the engine output in place; no host round-trip).
- Parameters:
wav24k – Host PCM float32 in [-1, 1] at 24kHz (truncated to the bucket if longer)
numFrames – Complete frames = floor(min(len, bucket) / downsampleRate)
-
inline int64_t const *refCodesDevice() const#
Device pointer to the last encodeReferenceCodes output [bucketFrames, numQuantizers] INT64.
-
inline bool hasTokenizerEncoder() const#
-
inline int64_t speakerEmbeddingDim() const#
-
inline int32_t numQuantizers() const#