The audio of one streamed request, read as the API generates it.

Iterate it (for await (const chunk of speech)) or read body, a web ReadableStream. Chunk sizes vary and are not aligned to samples. A failure after the first audio cuts the body: the iteration then throws a TextToSpeechError with retryable: true. So does a body that sends no audio for the request's readTimeout while a read waits for it; a read of body with your own reader then rejects with that error too. Aborting the request's signal stops the download, and the iteration throws the signal's reason (an AbortError unless you gave another) instead.

Implements

  • AsyncIterable<Uint8Array>

Constructors

Properties

Methods

Constructors

  • Parameters

    • info: TextToSpeechResponseInfo

      What the response headers say: model, voice, encoding, sample rate, request id.

    • body: ReadableStream<Uint8Array>

      The audio bytes as they arrive.

    • options: {
          signal?: AbortSignal;
      } = {}

      signal: the request's abort signal, whose abort ends the iteration with its reason.

      • Optionalsignal?: AbortSignal

    Returns TextToSpeechStream

Properties

body: ReadableStream<Uint8Array>

The audio bytes as they arrive.

What the response headers say: model, voice, encoding, sample rate, request id.

Methods

  • Returns AsyncIterator<Uint8Array, any, undefined>

  • Stops reading and releases the connection. Safe to call from outside a running for await (a barge-in callback): the loop then ends after the chunk it holds. When you read body with your own reader, cancel that reader instead.

    Returns Promise<void>