> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zeroruntime.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Google

> Python API reference for the google text-to-speech plugin.

<Card title="Usage guide" icon="book" href="/plugins/tts/google" horizontal>
  Setup, environment variables, and Python/JavaScript/Go usage examples.
</Card>

## 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

```python theme={null}
GoogleTTS(*, api_key: 'Optional[str]' = None, credentials_json: 'Optional[str]' = None, service_account_path: 'Optional[str]' = None, stream: 'bool' = True, voice: 'str' = 'en-US-Neural2-F', language_code: 'str' = 'en-US', model: 'GoogleTTSModel | str' = '', sample_rate: 'int' = 24000, speaking_rate: 'Optional[float]' = None, pitch: 'Optional[float]' = None, voice_config: 'Optional[GoogleVoiceConfig]' = None, **kwargs) -> 'None'
```

<ParamField path="api_key" type="Optional[str]">
  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.
</ParamField>

<ParamField path="credentials_json" type="Optional[str]">
  Service-account credentials as a raw JSON string or a path to a JSON key file. Takes highest precedence for authentication.
</ParamField>

<ParamField path="service_account_path" type="Optional[str]">
  Path to a service-account JSON key file. Used when `credentials_json` is not provided.
</ParamField>

<ParamField path="stream" type="bool" default="True">
  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.
</ParamField>

<ParamField path="voice" type="str" default="en-US-Neural2-F">
  Google Cloud TTS voice name following the pattern `&#123;language&#125;-&#123;region&#125;-&#123;Family&#125;-&#123;Character&#125;`, 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.
</ParamField>

<ParamField path="language_code" type="str" default="en-US">
  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.
</ParamField>

<ParamField path="model" type="GoogleTTSModel | str" default="">
  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`.
</ParamField>

<ParamField path="sample_rate" type="int" default="24000">
  Output audio sample rate in Hz. Default: `24000`.
</ParamField>

<ParamField path="speaking_rate" type="Optional[float]">
  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.
</ParamField>

<ParamField path="pitch" type="Optional[float]">
  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.
</ParamField>

<ParamField path="voice_config" type="Optional[GoogleVoiceConfig]">
  Optional `GoogleVoiceConfig` dataclass. When provided, its `name` and `languageCode` fields take precedence over `voice` / `language_code` if those parameters are still at their defaults.
</ParamField>

### aclose

```python theme={null}
def aclose(self) -> 'None'
```

Release any resources held by the provider.

### emit

```python theme={null}
def emit(self, event: 'T', *args: 'Any') -> 'None'
```

Emit an event, invoking all registered handlers with the given arguments.

Handlers are called in registration order. Coroutine handlers are
scheduled on the running event loop. If the emitter is closed, the call
is a no-op.

<ParamField path="event" type="T" required>
  The event to emit.
</ParamField>

### interrupt

```python theme={null}
def interrupt(self) -> 'None'
```

Interrupt and cancel the current synthesis for the active session, if any.

### off

```python theme={null}
def off(self, event: 'T', callback: 'Callable[..., Any]') -> 'None'
```

Remove a previously registered handler for an event.

If the handler is not registered for the event, the call is a no-op.

<ParamField path="event" type="T" required>
  The event the handler was registered for.
</ParamField>

<ParamField path="callback" type="Callable[..., Any]" required>
  The handler to remove.
</ParamField>

### on

```python theme={null}
def on(self, event: 'T', callback: 'Callable[..., Any] | None' = None) -> 'Callable[..., Any]'
```

Register a handler for an event.

Can be used directly by passing a callback, or as a decorator when
`callback` is omitted.

<ParamField path="event" type="T" required>
  The event to listen for.
</ParamField>

<ParamField path="callback" type="Callable[..., Any] | None">
  The handler to invoke when the event is emitted. If `None`, a decorator is returned that registers the decorated function.
</ParamField>

<ResponseField name="returns" type="Callable[..., Any]">
  The registered callback when `callback` is provided, otherwise a decorator that registers and returns the function it wraps.
</ResponseField>

### on\_first\_audio\_byte

```python theme={null}
def on_first_audio_byte(self, callback: "'Callable[[int, int], Awaitable[None] | None]'") -> 'None'
```

Register the callback invoked when the first audio byte is produced.

<ParamField path="callback" type="'Callable[[int, int], Awaitable[None] | None]'" required>
  A callable, optionally async, invoked with synthesis timing information when the first audio byte is emitted.
</ParamField>

### synthesize

```python theme={null}
def synthesize(self, text: 'Any', **kwargs: 'Any') -> 'None'
```

Synthesize the given text into speech.

Implementations should convert the text to audio. The default behavior
forwards the text to the active session for playback when one is present.

<ParamField path="text" type="Any" required>
  The text to synthesize; coerced to a string if needed.
</ParamField>

***

## GoogleTTSModel

```python theme={null}
GoogleTTSModel = typing.Literal['chirp3-hd', 'chirp-hd', 'studio', 'neural2', 'wavenet', 'standard', 'news', 'polyglot', 'chirp']
```
