What the response headers say: model, voice, encoding, sample rate, request id.
The audio bytes as they arrive.
signal: the request's abort signal, whose abort ends the iteration with its reason.
Optionalsignal?: AbortSignalReadonlybodyThe audio bytes as they arrive.
ReadonlyinfoWhat the response headers say: model, voice, encoding, sample rate, request id.
The audio of one streamed request, read as the API generates it.
Iterate it (
for await (const chunk of speech)) or readbody, a webReadableStream. Chunk sizes vary and are not aligned to samples. A failure after the first audio cuts the body: the iteration then throws aTextToSpeechErrorwithretryable: true. So does a body that sends no audio for the request'sreadTimeoutwhile a read waits for it; a read ofbodywith your own reader then rejects with that error too. Aborting the request'ssignalstops the download, and the iteration throws the signal's reason (anAbortErrorunless you gave another) instead.