<br />

Active streaming synthesis session returned by `TextToSpeech.synthesizeStream()`. Supports both pull-based `readNext()` and `for await (const chunk of stream)` iteration, as well as incremental text input via `pushText()` and `finishInput()`.

**Signature:**

```typescript
export declare class TextToSpeechStream implements AsyncIterable<TextToSpeechAudioChunk> 
```

## Methods

| Method | Modifiers | Description |
|---|---|---|
| [readNext()](https://developers.google.com/edge/api/mediapipe/js/tasks-audio.texttospeechstream.md.txt#texttospeechstreamreadnext) |   | Pulls the next synthesized PCM audio chunk, or returns `null` when the stream reaches end-of-stream. On a stream created with `finishInput = false`, waits for more text from `pushText()` or for `finishInput()` when the pushed text doesn't yet form a complete clause. |
| [pushText(textDelta)](https://developers.google.com/edge/api/mediapipe/js/tasks-audio.texttospeechstream.md.txt#texttospeechstreampushtext) |   | Appends an incremental text fragment (e.g. from an LLM token stream) to an open stream created with `finishInput = false`. |
| [finishInput()](https://developers.google.com/edge/api/mediapipe/js/tasks-audio.texttospeechstream.md.txt#texttospeechstreamfinishinput) |   | Marks the end of incremental text input on this stream, flushing any remaining partial sentence into the synthesis pipeline. |
| [cancel()](https://developers.google.com/edge/api/mediapipe/js/tasks-audio.texttospeechstream.md.txt#texttospeechstreamcancel) |   | Cancels this streaming synthesis session immediately. |
| [close()](https://developers.google.com/edge/api/mediapipe/js/tasks-audio.texttospeechstream.md.txt#texttospeechstreamclose) |   | Releases native stream resources. |
| [Symbol.asyncIterator()](https://developers.google.com/edge/api/mediapipe/js/tasks-audio.texttospeechstream.md.txt#texttospeechstreamsymbol_asynciterator) |   |   |

## TextToSpeechStream.readNext()

Pulls the next synthesized PCM audio chunk, or returns `null` when the stream reaches end-of-stream. On a stream created with `finishInput = false`, waits for more text from `pushText()` or for `finishInput()` when the pushed text doesn't yet form a complete clause.

**Signature:**

```typescript
readNext(): Promise<TextToSpeechAudioChunk | null>;
```

**Returns:**

Promise\<TextToSpeechAudioChunk \| null\>

## TextToSpeechStream.pushText()

Appends an incremental text fragment (e.g. from an LLM token stream) to an open stream created with `finishInput = false`.

**Signature:**

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

### Parameters

| Parameter | Type | Description |
|---|---|---|
| textDelta | string | The incremental text delta to append. |

**Returns:**

Promise\<void\>

## TextToSpeechStream.finishInput()

Marks the end of incremental text input on this stream, flushing any remaining partial sentence into the synthesis pipeline.

**Signature:**

```typescript
finishInput(): Promise<void>;
```

**Returns:**

Promise\<void\>

## TextToSpeechStream.cancel()

Cancels this streaming synthesis session immediately.

**Signature:**

```typescript
cancel(): void;
```

**Returns:**

void

## TextToSpeechStream.close()

Releases native stream resources.

**Signature:**

```typescript
close(): void;
```

**Returns:**

void

## TextToSpeechStream.Symbol.asyncIterator()

**Signature:**

```typescript
[Symbol.asyncIterator](): AsyncIterator<TextToSpeechAudioChunk>;
```

**Returns:**

AsyncIterator\<TextToSpeechAudioChunk\>