> ## 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 speech-to-text plugin.

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

## GoogleSTT

Google Cloud Speech-to-Text V2 plugin with streaming support.

Uses Google Cloud Speech-to-Text V2 recognition models (`latest_long` by
default, plus the Chirp family). Supports live streaming, speaker diarization,
word-level timing, and per-utterance voice-activity events.

### Constructor

```python theme={null}
GoogleSTT(*, credentials_json: 'Optional[str]' = None, service_account_path: 'Optional[str]' = None, api_key: 'Optional[str]' = None, project_id: 'Optional[str]' = None, stream: 'bool' = True, location: 'str' = 'us', languages: 'Union[str, list[str]]' = 'en-US', model: 'GoogleSTTModel | str' = 'latest_long', sample_rate: 'int' = 48000, audio_channel_count: 'int' = 1, interim_results: 'bool' = True, punctuate: 'bool' = True, profanity_filter: 'bool' = False, enable_spoken_punctuation: 'bool' = False, enable_spoken_emojis: 'bool' = False, enable_word_time_offsets: 'bool' = False, enable_word_confidence: 'bool' = False, max_alternatives: 'int' = 1, enable_voice_activity_events: 'bool' = False, speech_start_timeout: 'Optional[float]' = None, speech_end_timeout: 'Optional[float]' = None, min_speaker_count: 'Optional[int]' = None, max_speaker_count: 'Optional[int]' = None, min_confidence_threshold: 'float' = 0.0, **kwargs: 'Any') -> 'None'
```

<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="api_key" type="Optional[str]">
  Google API key. Used as a fallback credential source if the above are absent; the value is treated as a JSON file path first. For STT, service-account auth is recommended over API keys.
</ParamField>

<ParamField path="project_id" type="Optional[str]">
  Google Cloud project ID. Extracted automatically from the service-account JSON when not provided explicitly.
</ParamField>

<ParamField path="stream" type="bool" default="True">
  When `True` (default), audio is transcribed over a low-latency streaming connection. When `False`, a single-request (batch) call is used.
</ParamField>

<ParamField path="location" type="str" default="us">
  Cloud Speech-to-Text regional endpoint. `"us"` (default) or `"eu"`.
</ParamField>

<ParamField path="languages" type="Union[str, list[str]]" default="en-US">
  BCP-47 language code(s) for recognition, e.g. `"en-US"` (default) or `["en-US", "fr-FR"]`. Multiple codes enable multi-language detection.
</ParamField>

<ParamField path="model" type="GoogleSTTModel | str" default="latest_long">
  Recognition model ID. Known values (`GoogleSTTModel`): `"latest_long"` (default), `"latest_short"`, `"chirp_3"`, `"chirp_2"`, `"telephony"`, `"telephony_short"`.
</ParamField>

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

<ParamField path="audio_channel_count" type="int" default="1">
  Number of audio channels in the input. Default: `1` (mono).
</ParamField>

<ParamField path="interim_results" type="bool" default="True">
  When `True` (default), partial transcripts are emitted before an utterance is finalised.
</ParamField>

<ParamField path="punctuate" type="bool" default="True">
  When `True` (default), automatic punctuation is added to transcripts.
</ParamField>

<ParamField path="profanity_filter" type="bool" default="False">
  When `True`, profane words are replaced with placeholder characters. Default: `False`.
</ParamField>

<ParamField path="enable_spoken_punctuation" type="bool" default="False">
  When `True`, spoken punctuation cues (e.g. "period") are transcribed as punctuation marks. Default: `False`.
</ParamField>

<ParamField path="enable_spoken_emojis" type="bool" default="False">
  When `True`, spoken emoji names are transcribed as emoji characters. Default: `False`.
</ParamField>

<ParamField path="enable_word_time_offsets" type="bool" default="False">
  When `True`, start and end timestamps are returned for each recognised word. Default: `False`.
</ParamField>

<ParamField path="enable_word_confidence" type="bool" default="False">
  When `True`, per-word confidence scores are included in results. Default: `False`.
</ParamField>

<ParamField path="max_alternatives" type="int" default="1">
  Maximum number of alternative transcriptions to return. Default: `1`.
</ParamField>

<ParamField path="enable_voice_activity_events" type="bool" default="False">
  When `True`, speech-start and speech-end events are emitted independently of transcripts. Default: `False`.
</ParamField>

<ParamField path="speech_start_timeout" type="Optional[float]">
  Seconds to wait for speech to begin before a voice-activity timeout is triggered. `None` uses the API default.
</ParamField>

<ParamField path="speech_end_timeout" type="Optional[float]">
  Seconds of silence after speech before an end-of-speech voice-activity event is fired. `None` uses the API default.
</ParamField>

<ParamField path="min_speaker_count" type="Optional[int]">
  Minimum expected number of speakers for diarization. `None` disables diarization.
</ParamField>

<ParamField path="max_speaker_count" type="Optional[int]">
  Maximum expected number of speakers for diarization. `None` disables diarization.
</ParamField>

<ParamField path="min_confidence_threshold" type="float" default="0.0">
  Client-side filter; transcripts with a confidence score below this value are discarded. Range `0.0`–`1.0`. Default: `0.0` (no filtering).
</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>

### 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\_stt\_transcript

```python theme={null}
def on_stt_transcript(self, callback: 'Callable[[STTResponse], Awaitable[None]]') -> 'None'
```

Register the coroutine invoked when a transcription event is produced.

<ParamField path="callback" type="Callable[[STTResponse], Awaitable[None]]" required>
  An async callable that receives each `STTResponse`.
</ParamField>

### process\_audio

```python theme={null}
def process_audio(self, audio_frames: 'bytes', language: 'Optional[str]' = None, **kwargs: 'Any') -> 'None'
```

Process a chunk of audio for transcription.

Implementations should consume the audio frames and emit transcription
results through the registered transcript callback.

<ParamField path="audio_frames" type="bytes" required>
  Raw audio bytes to transcribe.
</ParamField>

<ParamField path="language" type="Optional[str]">
  Optional language code to guide recognition.
</ParamField>

### stream\_transcribe

```python theme={null}
def stream_transcribe(self, audio_stream: 'AsyncIterator[bytes]', **kwargs: 'Any') -> 'AsyncIterator[STTResponse]'
```

Transcribe a continuous audio stream.

<ParamField path="audio_stream" type="AsyncIterator[bytes]" required>
  An async iterator yielding raw audio byte chunks.
</ParamField>

<ResponseField name="returns" type="AsyncIterator[STTResponse]">
  STTResponse: Transcription events produced as audio is consumed.
</ResponseField>

***

## GoogleSTTModel

```python theme={null}
GoogleSTTModel = typing.Literal['chirp_3', 'chirp_2', 'latest_long', 'latest_short', 'telephony', 'telephony_short']
```
