Type Alias TextToSpeechRequestOptions

TextToSpeechRequestOptions: {
    readTimeout?: number;
    signal?: AbortSignal;
    timeout?: number;
}

Per-request options of the HTTP client.

Type declaration

  • OptionalreadTimeout?: number

    For stream(): milliseconds a read of the body may wait for audio, 30 000 by default; 0 turns it off. Only the time a read spends waiting counts, so playback at its own pace never trips it. A body that stalls without being reset (a dropped NAT mapping, a hung proxy) then ends with the same retryable TextToSpeechError as a cut, and the connection is released.

  • Optionalsignal?: AbortSignal

    An external abort signal, combined with the timeout. Aborting it rejects the request with the signal's reason; for stream() it also stops the download of the body, and the iteration throws that reason. One signal can serve many requests: each detaches from it when it ends.

  • Optionaltimeout?: number

    Milliseconds until the request is aborted with a DOMException named TimeoutError. For synthesize() the whole request, 610 000 by default (the response waits for the complete audio; the API caps a request at 600 seconds). For stream() the wait for the headers and first audio, 30 000 by default; each later read of the body is bounded by readTimeout instead.

    On Node, the built-in fetch also gives up after 300 seconds without response headers (undici's headersTimeout), so a synthesize() longer than that fails with a TypeError first. For longer requests use stream(), or raise that limit with setGlobalDispatcher(new Agent({ headersTimeout: 610_000 })) from the undici package.