TtsStream interface

An asynchronous stream of synthesized audio chunks supporting both pull-based iteration (for await (const chunk of stream)) and incremental text input (pushText() / finishInput()).

Signature:

export declare interface TtsStream extends AsyncIterable<TtsAudioChunk> 

Extends: AsyncIterable<TtsAudioChunk>

Methods

Method Description
[Symbol.asyncIterator]() Returns an async iterator yielding TtsAudioChunk objects as they are synthesized.
cancel() Cancels the active synthesis stream immediately.
close() Closes the stream and releases native streaming state.
finishInput() Signals that all text deltas have been pushed so the synthesizer can flush any remaining buffered text.
pushText(textDelta) Appends incremental text to the ongoing synthesis session (for example, tokens streamed from an LLM).
readNext() Reads the next synthesized audio chunk, or returns null when the stream has finished.

TtsStream.[Symbol.asyncIterator]()

Returns an async iterator yielding TtsAudioChunk objects as they are synthesized.

Signature:

[Symbol.asyncIterator](): AsyncIterator<TtsAudioChunk>;

Returns:

AsyncIterator<TtsAudioChunk>

TtsStream.cancel()

Cancels the active synthesis stream immediately.

Signature:

cancel(): void;

Returns:

void

TtsStream.close()

Closes the stream and releases native streaming state.

Signature:

close(): void;

Returns:

void

TtsStream.finishInput()

Signals that all text deltas have been pushed so the synthesizer can flush any remaining buffered text.

Signature:

finishInput(): Promise<void>;

Returns:

Promise<void>

TtsStream.pushText()

Appends incremental text to the ongoing synthesis session (for example, tokens streamed from an LLM).

Signature:

pushText(textDelta: string): Promise<void>;

Parameters

Parameter Type Description
textDelta string Additional text to append to the synthesis queue.

Returns:

Promise<void>

TtsStream.readNext()

Reads the next synthesized audio chunk, or returns null when the stream has finished.

Signature:

readNext(): Promise<TtsAudioChunk | null>;

Returns:

Promise<TtsAudioChunk | null>