Skip to main content

GoogleTTS

Google Cloud text-to-speech (TTS) provider. The model family must be consistent with voice; mismatches throw, and an unknown family is passed through (routing falls back to the voice name).

Constructor

apiKey
string | null
Google API key. Falls back to the GOOGLE_API_KEY environment variable, then null.
credentialsJson
string | null
Service-account credentials as a JSON string. Default null.
serviceAccountPath
string | null
Path to a service-account JSON key file. Default null.
stream
boolean
Stream audio from the model. Default true.
voice
string
Voice name to synthesize with (e.g. 'en-US-Neural2-F'). Default 'en-US-Neural2-F'.
languageCode
string
BCP-47 language code. Default 'en-US'.
model
GoogleTTSModel | string
Voice model family (e.g. 'neural2', 'wavenet', 'chirp3-hd'). Must match the voice’s family; omit (default '') to let the voice decide. Known families: standard, wavenet, neural2, news, polyglot, studio, chirp, chirp-hd, chirp3-hd.
sampleRate
number
Output audio sample rate in Hz. Default 24000.
speakingRate
number | null
Speaking rate (1.0 = normal). Must be in [0.25, 4.0]. Default null (provider default).
pitch
number | null
Voice pitch in semitones (0 = normal). Must be in [-20.0, 20.0]. Default null (provider default).
voiceConfig
GoogleVoiceConfig | null
Voice selection used as a fallback for voice and languageCode when those are left at their defaults. 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

GoogleTTSModel

Supported Google Cloud TTS voice model families.