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

# Sarvamai

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

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

## SarvamAISTT

Sarvam AI speech-to-text plugin using the saaras:v3 model.

Streams PCM audio to the Sarvam AI transcription API and emits text
transcripts.  Supports 23 Indic languages, multiple transcription modes
(transcribe, translate, verbatim, translit, codemix), and optional
server-side VAD controls.

### Constructor

```python theme={null}
SarvamAISTT(*, api_key: 'str | None' = None, model: 'SarvamAISTTModel | str' = 'saaras:v3', language: 'str' = 'en-IN', input_sample_rate: 'int' = 48000, output_sample_rate: 'int' = 16000, mode: 'Optional[str]' = None, high_vad_sensitivity: 'bool | None' = None, flush_signals: 'bool | None' = None, translation: 'bool' = False, prompt: 'str | None' = None, input_audio_codec: 'str' = 'pcm_s16le', vad_signals: 'bool | None' = True, positive_speech_threshold: 'float | None' = None, negative_speech_threshold: 'float | None' = None, min_speech_frames: 'int | None' = None, first_turn_min_speech_frames: 'int | None' = None, pre_speech_pad_frames: 'int | None' = None, interrupt_min_speech_frames: 'int | None' = None, **legacy_kwargs) -> 'None'
```

<ParamField path="api_key" type="str | None">
  Sarvam AI API key.  Falls back to the `SARVAM_API_KEY` environment variable when `None`.
</ParamField>

<ParamField path="model" type="SarvamAISTTModel | str" default="saaras:v3">
  Transcription model ID.  Defaults to `'saaras:v3'`, the current model with multi-mode support. `'saarika:v2.5'` is the alternative option.
</ParamField>

<ParamField path="language" type="str" default="en-IN">
  BCP-47 language code for the spoken audio.  Defaults to `'en-IN'`.  Supported values include `'hi-IN'`, `'bn-IN'`, `'kn-IN'`, `'ml-IN'`, `'mr-IN'`, `'od-IN'`, `'pa-IN'`, `'ta-IN'`, `'te-IN'`, `'gu-IN'`, `'as-IN'`, `'ur-IN'`, `'ne-IN'`, and others.  Use `'unknown'` for automatic language detection.
</ParamField>

<ParamField path="input_sample_rate" type="int" default="48000">
  Sample rate (Hz) of the incoming audio. Defaults to `48000` (the standard capture rate).
</ParamField>

<ParamField path="output_sample_rate" type="int" default="16000">
  Sample rate (Hz) expected by the Sarvam API. Defaults to `16000`.  PCM audio is resampled as needed.
</ParamField>

<ParamField path="mode" type="Optional[str]">
  Transcription mode passed to the API.  `None` (default) uses the API default (`'transcribe'`).  Other `saaras:v3` values: `'translate'` (Indic → English), `'verbatim'` (no normalisation), `'translit'` (Romanisation), `'codemix'` (mixed-script output).
</ParamField>

<ParamField path="high_vad_sensitivity" type="bool | None">
  When `True`, increases server-side VAD sensitivity to detect quieter speech.  `None` lets the API choose.
</ParamField>

<ParamField path="flush_signals" type="bool | None">
  When `True`, enables end-of-utterance flush signals so the server emits partial transcripts at turn boundaries.  `None` lets the API choose.
</ParamField>

<ParamField path="translation" type="bool" default="False">
  When `True`, requests translation of the transcript to English (shorthand for `mode='translate'`).  Defaults to `False`.
</ParamField>

<ParamField path="prompt" type="str | None">
  Optional text hint that biases transcription towards domain-specific vocabulary or proper nouns.
</ParamField>

<ParamField path="input_audio_codec" type="str" default="pcm_s16le">
  Codec identifier for PCM audio sent to the API. Defaults to `'pcm_s16le'`.  Other PCM variants: `'pcm_l16'`, `'pcm_raw'`.
</ParamField>

<ParamField path="vad_signals" type="bool | None" default="True">
  When `True` (default), the server emits VAD activity signals alongside transcripts.
</ParamField>

<ParamField path="positive_speech_threshold" type="float | None">
  Probability threshold (0–1) above which a frame is considered speech.  `None` uses the API default.
</ParamField>

<ParamField path="negative_speech_threshold" type="float | None">
  Probability threshold (0–1) below which a frame is considered silence.  `None` uses the API default.
</ParamField>

<ParamField path="min_speech_frames" type="int | None">
  Minimum consecutive speech frames required before an utterance is opened.  `None` uses the API default.
</ParamField>

<ParamField path="first_turn_min_speech_frames" type="int | None">
  Override for `min_speech_frames` on the very first turn only.  `None` uses the API default.
</ParamField>

<ParamField path="pre_speech_pad_frames" type="int | None">
  Number of audio frames prepended to each utterance to avoid clipping the first phoneme.  `None` uses the API default.
</ParamField>

<ParamField path="interrupt_min_speech_frames" type="int | None">
  Minimum speech frames to trigger an interruption signal.  `None` uses the API default.
</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>

***

## SarvamAISTTModel

```python theme={null}
SarvamAISTTModel = typing.Literal['saaras:v3']
```
