Usage guide
Setup, environment variables, and Python/JavaScript/Go usage examples.
GoogleTTS
Google Cloud Text-to-Speech plugin with streaming output. Synthesises speech using the Google Cloud TTS API, supporting the full voice family range from Standard through Chirp3-HD. Voices are selected by name; the model family is inferred from the voice name automatically.Constructor
Google API key. Also used as a fallback credential source (treated as a JSON file path first). Falls back to the
GOOGLE_API_KEY env var.Service-account credentials as a raw JSON string or a path to a JSON key file. Takes highest precedence for authentication.
Path to a service-account JSON key file. Used when
credentials_json is not provided.When
True (default), audio is streamed back progressively for lower time-to-first-audio. When False, the full synthesis result is returned in one response.Google Cloud TTS voice name following the pattern
{language}-{region}-{Family}-{Character}, e.g. "en-US-Neural2-F" (default, Neural2 female US English). The voice name implicitly determines the model family; see model for details. Overridden by voice_config.name when a voice_config is supplied and the default is active.BCP-47 language code for the voice, e.g.
"en-US" (default). Overridden by voice_config.languageCode when a voice_config is supplied and the default is active.Voice family override. Known values (
GoogleTTSModel): "chirp3-hd", "chirp-hd", "studio", "neural2" , "wavenet", "standard", "news", "polyglot", "chirp". Leave empty (default "") to let the voice name determine the family. Raises ValueError if the explicit model contradicts the family implied by voice.Output audio sample rate in Hz. Default:
24000.Playback speed multiplier. Range
[0.25, 4.0]; 1.0 is native speed (API default). None omits the parameter and lets the API use its default.Pitch shift in semitones. Range
[-20.0, 20.0]; 0.0 is the original pitch. None omits the parameter. Raises ValueError outside the valid range.Optional
GoogleVoiceConfig dataclass. When provided, its name and languageCode fields take precedence over voice / language_code if those parameters are still at their defaults.aclose
emit
The event to emit.
interrupt
off
The event the handler was registered for.
The handler to remove.
on
callback is omitted.
The event to listen for.
The handler to invoke when the event is emitted. If
None, a decorator is returned that registers the decorated function.The registered callback when
callback is provided, otherwise a decorator that registers and returns the function it wraps.on_first_audio_byte
A callable, optionally async, invoked with synthesis timing information when the first audio byte is emitted.
synthesize
The text to synthesize; coerced to a string if needed.