Skip to main content

GenerationConfig

Grouped generation settings for CartesiaTTS. Flat options on CartesiaTTSOptions take precedence over the matching field here.

Constructor

speed
number | null
emotion
string | null
volume
number | null
pronunciationDictId
string | null
maxBufferDelayMs
number | null
enableWordTimestamps
boolean

CartesiaTTS

Cartesia text-to-speech provider. Creates a configured Cartesia TTS provider for use in a voice agent.

Constructor

apiKey
string
Cartesia API key. Falls back to the CARTESIA_API_KEY env var.
voice
string | number[] | null
Voice as a catalog UUID (string) or a cloning embedding (non-empty number array). Default: a built-in voice UUID.
voiceId
string | number[] | null
Alias for voice; used when voice is not set.
model
CartesiaTTSModel | string
Synthesis model. Default: 'sonic-2'.
language
string
Synthesis language code. Default: 'en'.
sampleRate
number
Output audio sample rate in Hz. Default: 24000. (The effective rate is fixed; other values are ignored.)
speed
number | null
Speaking speed. Default: null (or generationConfig.speed).
volume
number | null
Output volume. Default: null (or generationConfig.volume).
emotion
string | null
Emotion tag. Default: null (or generationConfig.emotion).
pronunciationDictId
string | null
Pronunciation dictionary ID. Default: null (or generationConfig.pronunciationDictId).
maxBufferDelayMs
number | null
Max buffering delay in ms. Default: null (or generationConfig.maxBufferDelayMs).
enableWordTimestamps
boolean | null
Emit per-word timestamps. Default: false (or generationConfig.enableWordTimestamps).
generationConfig
GenerationConfig | null
Grouped generation settings; flat options above take precedence. Default: null.

close

Release any resources held by the provider.

closeEmitter

Close the emitter: drop all handlers and stop emitting. Waits up to 2 seconds for in-flight async handlers to settle before returning.

emit

event
string
required

getRuntimeConfig

returns
Record<string, any>

interrupt

Stop the current synthesis.

listenerCount

event
string
required
returns
number

off

event
string
required
handler
EventHandler
required

on

event
string
required
handler
EventHandler
required
returns
EventHandler

once

event
string
required
handler
EventHandler
required
returns
EventHandler

onFirstAudioByte

Register a callback fired when the first synthesized audio byte is emitted.
callback
FirstAudioByteCallback
required

removeAllListeners

event
string

synthesize

Synthesize and speak text on the active session.
text
any
required

CartesiaTTSModel

Supported Cartesia text-to-speech model names.