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 TextToSpeechStream extends AsyncIterable<TextToSpeechAudioChunk>
Extends: AsyncIterable<TextToSpeechAudioChunk>
Methods
| Method | Description |
|---|---|
| [Symbol.asyncIterator]() | Returns an async iterator yielding TextToSpeechAudioChunk 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. |
TextToSpeechStream.[Symbol.asyncIterator]()
Returns an async iterator yielding TextToSpeechAudioChunk objects as they are synthesized.
Signature:
[Symbol.asyncIterator](): AsyncIterator<TextToSpeechAudioChunk>;
Returns:
AsyncIterator<TextToSpeechAudioChunk>
TextToSpeechStream.cancel()
Cancels the active synthesis stream immediately.
Signature:
cancel(): void;
Returns:
void
TextToSpeechStream.close()
Closes the stream and releases native streaming state.
Signature:
close(): void;
Returns:
void
TextToSpeechStream.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>
TextToSpeechStream.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>
TextToSpeechStream.readNext()
Reads the next synthesized audio chunk, or returns null when the stream has finished.
Signature:
readNext(): Promise<TextToSpeechAudioChunk | null>;
Returns:
Promise<TextToSpeechAudioChunk | null>