Skip to main content
Google Cloud Text-to-Speech is a text-to-speech plugin. It synthesizes the LLM’s reply into the agent’s voice. It occupies the pipeline’s tts slot.

Setup

Cloud TTS authenticates with either a service account or an API key. Create one in the Google Cloud console and export it in the worker environment:
Streaming synthesis needs a service account. Cloud TTS refuses an API key on StreamingSynthesize, and streaming defaults to True — so an API key alone works only with streaming=False. The plugin also prefers GOOGLE_API_KEY whenever it is set: leave it unset when you mean to authenticate with the service account.

Credential resolution

The plugin chooses one credential when it is constructed, and takes the first that is present:
  1. GOOGLE_API_KEY when it is unset it will use GOOGLE_APPLICATION_CREDENTIALS.
  2. GOOGLE_APPLICATION_CREDENTIALS, when it points at a readable file — used as service-account credentials.
The fallback is on absence, not on failure. Step 2 is reached only when no API key is set at all — so if GOOGLE_API_KEY is present and Google rejects it, the plugin does not then try the service-account file, even when both are configured. Unset GOOGLE_API_KEY to make the service account the credential in use.

Usage

Import the plugin and pass it to the pipeline’s tts slot.
Everything about the voice lives in voice_config — there is no separate voice or language_code argument. Omit it entirely and the plugin uses en-US-Chirp3-HD-Charon / en-US / MALE.

Streaming

streaming=True (the default) synthesizes over gRPC StreamingSynthesize, which starts returning audio while the LLM is still producing text. Without a Gemini-TTS model, that path only accepts Chirp 3 HD voices; any other voice raises ValueError from the constructor. For a Neural2, Studio, WaveNet, or Standard voice, turn streaming off and the plugin falls back to per-segment SynthesizeSpeech requests:
pitch is only sent on the non-streaming path — Cloud TTS’s streaming audio config carries speaking_rate but has no pitch field, so pitch is silently inert when streaming=True.
streaming=True and vertexai=True cannot be combined; the constructor raises ValueError.

Gemini-TTS

Set model to a Gemini-TTS engine to synthesize with Gemini instead of standard Cloud TTS. The voice name becomes a bare Gemini voice, and prompt takes a natural-language style instruction:
Known engines are "gemini-3.1-flash-tts-preview", "gemini-2.5-flash-tts", "gemini-2.5-flash-lite-preview-tts", and "gemini-2.5-pro-tts". A Gemini model lifts the Chirp 3 HD restriction on streaming, and prompt is only valid alongside one — passing prompt without model raises ValueError.

Vertex AI

vertexai=True routes synthesis through the regional Vertex AI endpoint ({location}-texttospeech.googleapis.com) using Application Default Credentials rather than an API key. It requires streaming=False.

Custom pronunciations

custom_pronunciations overrides how specific phrases are read. The short form is a mapping of phrase to IPA:
The long form is a list, and lets each entry pick its phonetic encoding — "ipa" (default) or "x-sampa". An unrecognized encoding logs a warning and falls back to IPA:
Cloud TTS only applies custom pronunciations to en-US. With any other languageCode the plugin logs a warning and the overrides are ignored.
They apply on both the streaming and non-streaming paths.

Parameters

Constructor parameters for GoogleTTS. The Python and Node JS SDKs share these field names. Output audio is fixed at 24 kHz, mono, 16-bit PCM — there is no sample_rate argument.

Import paths

The same plugin is also reachable without a Google credential of your own, billed against your Zero Runtime token, as from zeroruntime.inference import GoogleTTS — see Zero Runtime inference. The synthesized audio is streamed back to the caller as the final stage of the pipeline.