SpeechSynthesizer
classin packageklyn.genai.tts
public class SpeechSynthesizer implements AutoClosable
SpeechSynthesizer
All Implemented Interfaces: AutoClosable

Resident Qwen3-TTS CustomVoice synthesis from GGUF or original HF Safetensors, implemented in Klyn/C++ using the existing Klyn NN backend. No additional inference library, Python service or external executable is used. Synthesis produces typed PCM, never implicit playback or microphone activation. Auto selects a compatible NVIDIA GPU, otherwise CPU. Packed projections execute on that device; causal audio kernels use synchronized CPU storage. An explicit GPU never falls back. NPU execution is not available yet. A synthesizer is single-owner; only SpeechStream.cancel is cross-thread.

Example

try speech = SpeechSynthesizer.load("sakasegawa/Qwen3-TTS-12Hz-0.6B-CustomVoice-GGUF"): speech.synthesize("Hello", voice="ryan", language="en").play()

Properties
Modifier and Type Member Description
public readonly property device
device as Device = Device.cpu
Actual device, not the original selector.
public readonly property sampleRate
sampleRate as Int
Output frequency in Hz.
public readonly property voices
voices as String[]
Fresh array of built-in voice names.
Constructors
Modifier and Type Member Description
public SpeechSynthesizer
SpeechSynthesizer(notnull folder as FolderPath, notnull device as Device = Device.auto, maxContext as Long = 1024l, maxFrames as Long = 512l, seed as ULong = 0ul, verbose as Boolean = false)
Opens original HF Safetensors with the nested speech_tokenizer codec.
public SpeechSynthesizer
SpeechSynthesizer(notnull path as FilePath, notnull device as Device = Device.auto, maxContext as Long = 1024l, maxFrames as Long = 512l, seed as ULong = 0ul, verbose as Boolean = false)
Opens a local CustomVoice GGUF and keeps its parameters resident.
Methods
Modifier and Type Member Description
public override close
close() as Void
Cancels and joins the active worker, then releases model parameters.
public static load
load(notnull repository as String, quantization as ModelQuantization = ModelQuantization.AUTO, notnull device as Device = Device.auto, maxContext as Long = 1024l, maxFrames as Long = 512l, seed as ULong = 0ul, revision as String = "main", offline as Boolean = false, verbose as Boolean = false, token as String = "", format as ModelFormat = ModelFormat.AUTO) as SpeechSynthesizer
Resolves a pinned Hub quantization through the shared verified cache, then loads it.
public stream
stream(notnull text as String, notnull voice as String = "", notnull language as String = "auto", notnull instructions as String = "") as SpeechStream
Starts bounded, cancellable incremental synthesis on a registered Klyn worker.
public synthesize
synthesize(notnull text as String, notnull voice as String = "", notnull language as String = "auto", notnull instructions as String = "") as AudioClip
Produces a complete independent mono Float32 clip without playback.
Inherited Methods
methodInherited Methods from AutoClosable: close