Skip to main content

Usage guide

Setup, environment variables, and Python/JavaScript/Go usage examples.

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

api_key
str | None
Sarvam AI API key. Falls back to the SARVAM_API_KEY environment variable when None.
model
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.
language
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.
input_sample_rate
int
default:"48000"
Sample rate (Hz) of the incoming audio. Defaults to 48000 (the standard capture rate).
output_sample_rate
int
default:"16000"
Sample rate (Hz) expected by the Sarvam API. Defaults to 16000. PCM audio is resampled as needed.
mode
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).
high_vad_sensitivity
bool | None
When True, increases server-side VAD sensitivity to detect quieter speech. None lets the API choose.
flush_signals
bool | None
When True, enables end-of-utterance flush signals so the server emits partial transcripts at turn boundaries. None lets the API choose.
translation
bool
default:"False"
When True, requests translation of the transcript to English (shorthand for mode='translate'). Defaults to False.
prompt
str | None
Optional text hint that biases transcription towards domain-specific vocabulary or proper nouns.
input_audio_codec
str
default:"pcm_s16le"
Codec identifier for PCM audio sent to the API. Defaults to 'pcm_s16le'. Other PCM variants: 'pcm_l16', 'pcm_raw'.
vad_signals
bool | None
default:"True"
When True (default), the server emits VAD activity signals alongside transcripts.
positive_speech_threshold
float | None
Probability threshold (0–1) above which a frame is considered speech. None uses the API default.
negative_speech_threshold
float | None
Probability threshold (0–1) below which a frame is considered silence. None uses the API default.
min_speech_frames
int | None
Minimum consecutive speech frames required before an utterance is opened. None uses the API default.
first_turn_min_speech_frames
int | None
Override for min_speech_frames on the very first turn only. None uses the API default.
pre_speech_pad_frames
int | None
Number of audio frames prepended to each utterance to avoid clipping the first phoneme. None uses the API default.
interrupt_min_speech_frames
int | None
Minimum speech frames to trigger an interruption signal. None uses the API default.

aclose

Release any resources held by the provider.

emit

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.
event
T
required
The event to emit.

off

Remove a previously registered handler for an event. If the handler is not registered for the event, the call is a no-op.
event
T
required
The event the handler was registered for.
callback
Callable[..., Any]
required
The handler to remove.

on

Register a handler for an event. Can be used directly by passing a callback, or as a decorator when callback is omitted.
event
T
required
The event to listen for.
callback
Callable[..., Any] | None
The handler to invoke when the event is emitted. If None, a decorator is returned that registers the decorated function.
returns
Callable[..., Any]
The registered callback when callback is provided, otherwise a decorator that registers and returns the function it wraps.

on_stt_transcript

Register the coroutine invoked when a transcription event is produced.
callback
Callable[[STTResponse], Awaitable[None]]
required
An async callable that receives each STTResponse.

process_audio

Process a chunk of audio for transcription. Implementations should consume the audio frames and emit transcription results through the registered transcript callback.
audio_frames
bytes
required
Raw audio bytes to transcribe.
language
Optional[str]
Optional language code to guide recognition.

stream_transcribe

Transcribe a continuous audio stream.
audio_stream
AsyncIterator[bytes]
required
An async iterator yielding raw audio byte chunks.
returns
AsyncIterator[STTResponse]
STTResponse: Transcription events produced as audio is consumed.

SarvamAISTTModel