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

Single-consumer incremental synthesis with at most 64 KiB of queued PCM. read() applies backpressure, never dropping samples. cancel() may be called from another thread; close() belongs to the consumer and joins the producer. No callback executes application code on the synthesis worker.

Example

try stream = synthesizer.stream("Hello", voice="ryan", language="en"): block = stream.read()

Properties
Modifier and Type Member Description
public readonly property channels
channels as Int = 1
One mono channel.
public readonly property generatedSamples
generatedSamples as ULong
Generated scalar samples, including queued blocks; retained after closure.
public readonly property isCancelled
isCancelled as Boolean
Whether cancellation was requested.
public readonly property isClosed
isClosed as Boolean
Whether ownership was released.
public readonly property isFinished
isFinished as Boolean
True after read() observed end, or after closure.
public readonly property sampleRate
sampleRate as Int
Output frame rate in Hz.
Constructors
Modifier and Type Member Description
public SpeechStream
SpeechStream(notnull task as SpeechGenerationTask, notnull queue as PcmQueue, sampleRate as Int)
Binds an owned queue and registered Klyn generation task.
Methods
Modifier and Type Member Description
public cancel
cancel() as Void
Requests cooperative cancellation and discards unread blocks.
public override close
close() as Void
Cancels, joins and frees queue ownership.
public read
read() as AudioClip
Waits for PCM; null means end/cancellation.
Inherited Methods
methodInherited Methods from AutoClosable: close