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

# Deepgram

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

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

## DeepgramTTS

Low-latency streaming text-to-speech via Deepgram's Aura-2 Speak API.

Natural English neural voices selected by model id (one voice per model).

### Constructor

```python theme={null}
DeepgramTTS(*, api_key: 'str | None' = None, voice: 'Optional[str]' = None, model: 'DeepgramTTSModel | str' = 'aura-2-andromeda-en', sample_rate: 'int' = 24000, stream: 'bool' = True, encoding: 'str' = 'linear16', base_url: 'str' = 'wss://api.deepgram.com/v1/speak', **kwargs) -> 'None'
```

<ParamField path="api_key" type="str | None">
  Deepgram API key. Falls back to `DEEPGRAM_API_KEY`.
</ParamField>

<ParamField path="voice" type="Optional[str]">
  Voice override; when set, takes precedence over `model` as the Aura voice id. Defaults to the `model` value.
</ParamField>

<ParamField path="model" type="DeepgramTTSModel | str" default="aura-2-andromeda-en">
  Aura-2 voice, e.g. `aura-2-andromeda-en`, `aura-2-thalia-en`, `aura-2-asteria-en`, `aura-2-zeus-en` (16 English voices). Default `"aura-2-andromeda-en"`.
</ParamField>

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

<ParamField path="stream" type="bool" default="True">
  Stream audio as it is synthesized. Default True.
</ParamField>

<ParamField path="encoding" type="str" default="linear16">
  Output audio encoding. Default `"linear16"`.
</ParamField>

<ParamField path="base_url" type="str" default="wss://api.deepgram.com/v1/speak">
  Deepgram Speak WebSocket endpoint.
</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>

***

## DeepgramTTSModel

```python theme={null}
DeepgramTTSModel = typing.Literal['aura-2-andromeda-en', 'aura-2-thalia-en', 'aura-2-asteria-en', 'aura-2-luna-en', 'aura-2-orion-en', 'aura-2-arcas-en', 'aura-2-zeus-en', 'aura-2-hera-en', 'aura-2-athena-en', 'aura-2-a …
```
