Type Alias TextToSpeechSessionParams

TextToSpeechSessionParams: {
    apiKey?: string;
    connectTimeout?: number;
    encoding?: LiteralUnion<Exclude<TextToSpeechEncoding, "mp3">, string>;
    extendBiometricConsent?: boolean;
    inactivityTimeout?: number;
    language?: LiteralUnion<TextToSpeechLanguage, string>;
    modelId?: string;
    sampleRate?: TextToSpeechSampleRate;
    terminateTimeout?: number;
    token?: string;
    voiceId?: string;
    websocketBaseUrl?: string;
    wordBoundaries?: boolean;
}

Parameters of a TextToSpeechSession.

Type declaration

  • OptionalapiKey?: string

    The API key; the client's key is used when neither this nor token is given.

  • OptionalconnectTimeout?: number

    Milliseconds to wait for the handshake and Begin. Defaults to 10 000.

  • Optionalencoding?: LiteralUnion<Exclude<TextToSpeechEncoding, "mp3">, string>

    pcm_s16le (default), pcm_mulaw or pcm_alaw. A session has no MP3 or container.

  • OptionalextendBiometricConsent?: boolean

    true renews the biometric consent of the cloned voice in voiceId. Needs voiceId. connect() is refused with not_owner (close 3006, param: "extend_biometric_consent") on a voice the account does not own, and with biometric_terms_not_accepted (close 3006, not retryable) until the account accepts the biometric data terms on the data controls page of the AssemblyAI dashboard. The Termination summary's voice_expires_at shows the new expiry.

  • OptionalinactivityTimeout?: number

    Seconds (5 to 120, default 120) without a frame in either direction after which the API closes the session (3006 inactivity_timeout, retryable). See keepAlive().

  • Optionallanguage?: LiteralUnion<TextToSpeechLanguage, string>
  • OptionalmodelId?: string
  • OptionalsampleRate?: TextToSpeechSampleRate

    Defaults to 24000.

  • OptionalterminateTimeout?: number

    Milliseconds without a message from the API after which close() stops waiting for Termination and drops the audio still to come; 0 waits indefinitely. Defaults to 35 000, a little over the API's own 30 s limit for a stalled drain.

  • Optionaltoken?: string

    A temporary token, for a session opened on a user's device. It is sent instead of the API key and opens one connection: to reconnect, pass a new token to connect({ token }). The API may refuse a token it has already seen, and always refuses an expired one, with close code 1008 (unauthorized).

  • OptionalvoiceId?: string

    See TextToSpeechVoiceOptions.voice_id.

  • OptionalwebsocketBaseUrl?: string

    Defaults to wss://tts.us.assemblyai.com/v1/ws; wss://tts.eu.assemblyai.com/v1/ws for the EU zone.

  • OptionalwordBoundaries?: boolean

    Whether the server sends wordBoundaries events. Off by default here.