Overview
Sarvam AI offers two real-time speech recognition services for Indian languages:SarvamSTTService: Uses Sarvam’s transcription WebSocket API with VAD-based segmentation and multiple audio formats (saaras:v3model)SarvamRealtimeSTTService: Uses Sarvam’s realtime WebSocket endpoint (saaras:v3-realtimemodel) with server-side endpointing, in-band configuration updates, and lower latency
Sarvam STT API Reference
Pipecat’s API methods for Sarvam STT integration
SarvamSTTService Example
Complete example with VAD-based turn detection
SarvamRealtimeSTTService Example
Realtime STT with manual endpointing
Sarvam Documentation
Official Sarvam AI STT documentation and features
Sarvam AI Platform
Access API keys and speech models
Installation
To use Sarvam services, install the required dependency:Prerequisites
Sarvam AI Account Setup
Before using Sarvam STT services, you need:- Sarvam AI Account: Sign up at Sarvam AI
- API Key: Generate an API key from your account dashboard
- Model Access:
SarvamSTTService: Access to Saarika (STT) or Saaras (STT-Translate) models, including thesaaras:v3model with support for multiple modes (transcribe, translate, verbatim, translit, codemix)SarvamRealtimeSTTService: Access to thesaaras:v3-realtimemodel
Required Environment Variables
SARVAM_API_KEY: Your Sarvam AI API key for authentication
Configuration
SarvamSTTService
str
required
Sarvam API key for authentication.
str
default:"saaras:v3"
deprecated
Sarvam model to use. Allowed values:
"saarika:v2.5" (standard STT),
"saaras:v2.5" (STT-Translate, auto-detects language), "saaras:v3"
(advanced, supports mode and fine-grained VAD). Deprecated in v0.0.105. Use
settings=SarvamSTTService.Settings(...) instead.int
default:"None"
Audio sample rate in Hz. Defaults to 16000 if not specified.
Literal['transcribe', 'translate', 'verbatim', 'translit', 'codemix']
default:"None"
Mode of operation. Only applicable to models that support it (e.g.,
saaras:v3). Defaults to the model’s default mode.str
default:"wav"
Audio codec/format of the input file.
SarvamSTTService.InputParams
default:"None"
deprecated
Configuration parameters for Sarvam STT service. Deprecated in v0.0.105. Use
settings=SarvamSTTService.Settings(...) instead.SarvamSTTService.Settings
default:"None"
Runtime-configurable settings for the STT service. See Settings
below.
float
default:"None"
Seconds of no audio before sending silence to keep the connection alive.
None disables keepalive.float
default:"SARVAM_TTFS_P99"
P99 latency from speech end to final transcript in seconds. Override for your
deployment. See stt-benchmark.
float
default:"5.0"
Seconds between idle checks when keepalive is enabled.
Settings
Runtime-configurable settings passed via thesettings constructor argument using SarvamSTTService.Settings(...). These can be updated mid-conversation with STTUpdateSettingsFrame. See Service Settings for details.
SarvamRealtimeSTTService
str
required
Sarvam API key for authentication.
str
default:"wss://api.sarvam.ai/speech-to-text-realtime/ws"
Realtime STT websocket endpoint.
Literal['vad', 'manual']
default:"vad"
Which side detects turn boundaries:
vad for Sarvam’s own detection, or
manual for the pipeline’s. Decides the turn strategies this service asks the
user aggregator to run. Defaults to vad.int
default:"None"
Declared input audio sample rate, 8000 or 16000.
None adopts the pipeline’s
input rate.bool
default:"False"
Whether final transcripts should include segment offsets.
int
default:"None"
Optional VAD prefix padding, used only under
endpointing="vad".SarvamRealtimeSTTService.Settings
default:"None"
Runtime-updatable realtime settings. See Realtime
Settings below.
bool
default:"True"
Whether the bot should be interrupted when Sarvam detects user speech. Passed
to the user turn strategies this service recommends.
float
default:"SARVAM_REALTIME_TTFS_P99"
P99 latency from speech end to final transcript in seconds. Override for your
deployment.
Realtime Settings
Runtime-configurable settings passed via thesettings constructor argument using SarvamRealtimeSTTService.Settings(...). These can be updated mid-conversation via config.update() or STTUpdateSettingsFrame.
Usage
Basic Setup (SarvamSTTService)
With Language and Model Configuration
With Server-Side VAD
Basic Realtime Setup
Realtime with Language and Stream Type
Realtime with Manual Endpointing
Updating Realtime Configuration
Notes
SarvamSTTService
- Default model changed: As of this update, the default model is
saaras:v3(previouslysaarika:v2.5). Applications that relied on the previous default should setsettings=SarvamSTTService.Settings(model="saarika:v2.5")explicitly. - Supported languages: Bengali (bn-IN), Gujarati (gu-IN), Hindi (hi-IN), Kannada (kn-IN), Malayalam (ml-IN), Marathi (mr-IN), Tamil (ta-IN), Telugu (te-IN), Punjabi (pa-IN), Odia (od-IN), English (en-IN), and Assamese (as-IN).
- Model-specific parameter validation: The service validates that parameters are compatible with the selected model. For example,
promptis only supported withsaaras:v2.5,languageis not supported withsaaras:v2.5(which auto-detects language), and the fine-grained VAD parameters are only supported withsaaras:v3. - Fine-grained VAD tuning (saaras:v3 only): The
saaras:v3model supports server-side VAD with 10 tuning parameters for speech detection thresholds, frame-count controls, pre-speech padding, interruption sensitivity, and initial-frame skipping. These parameters are only available with thesaaras:v3model. - VAD modes: When
vad_signals=False(default), the service relies on Pipecat’s local VAD and flushes the server buffer onVADUserStoppedSpeakingFrame. Whenvad_signals=True, the service uses Sarvam’s server-side VAD and broadcasts speaking frames from the server.
SarvamRealtimeSTTService
- Supported sample rates: Only 8000 Hz and 16000 Hz are supported. The service validates the sample rate at initialization.
- Supported languages:
auto, Bengali (bn-IN), Gujarati (gu-IN), Hindi (hi-IN), Kannada (kn-IN), Malayalam (ml-IN), Marathi (mr-IN), Tamil (ta-IN), Telugu (te-IN), Punjabi (pa-IN), Odia (or-IN), English (en-IN), Assamese (as-IN), Urdu (ur-IN), Nepali (ne-IN), Konkani (kok-IN), Kashmiri (ks-IN), Sindhi (sd-IN), Sanskrit (sa-IN), Santali (sat-IN), Manipuri (mni-IN), Bodo (brx-IN), Maithili (mai-IN), and Dogri (doi-IN). - Endpointing modes:
endpointing="vad"(default): Sarvam’s server-side VAD decides turn boundaries. The service proposes turn frames viaProposedUserStartedSpeakingFrameandProposedUserStoppedSpeakingFrame.endpointing="manual": The pipeline drives turn boundaries viaVADUserStartedSpeakingFrameandVADUserStoppedSpeakingFrame. Requires a VAD analyzer on the user aggregator.
- VAD analyzer required: A VAD analyzer is required in either endpointing mode. Under
vadit times transcription latency; undermanualit also marks the turn for Sarvam. - In-band configuration updates: Settings can be updated mid-conversation via
update_config()without reconnecting. Connection-only values (sample_rate,return_timestamps,prefix_padding_ms,endpointing) cannot be updated at runtime. - Stream types:
fastprovides lowest latency,balancedprovides moderate latency with better quality, andsimulatedis for testing. The stream type controls server-side flush cadence; the client always sends audio in 50ms chunks.
Event Handlers
In addition to the standard service connection events (on_connected, on_disconnected, on_connection_error), Sarvam STT provides: