Overview
SarvamTTSService provides text-to-speech synthesis specialized for Indian languages and voices. The service offers extensive voice customization options including pitch, pace, and loudness control, with support for multiple Indian languages and preprocessing for mixed-language content. The bulbul:v3-beta model adds temperature control and 25 new speaker voices.
Sarvam TTS API Reference
Pipecat’s API methods for Sarvam AI TTS integration
Example Implementation
Complete example with Indian language support
Sarvam Documentation
Official Sarvam AI text-to-speech API documentation
Sarvam Console
Access Indian language voices and API keys
Installation
To use Sarvam AI services, no additional dependencies are required beyond the base installation:Prerequisites
Sarvam AI Account Setup
Before using Sarvam AI TTS services, you need:- Sarvam AI Account: Sign up at Sarvam AI Console
- API Key: Generate an API key from your account dashboard
- Language Selection: Choose from available Indian language voices
Required Environment Variables
SARVAM_API_KEY: Your Sarvam AI API key for authentication
Configuration
Sarvam offers two service implementations:SarvamTTSService (WebSocket) for real-time streaming and SarvamHttpTTSService (HTTP) for simpler batch synthesis.
SarvamTTSService
Sarvam AI API subscription key.
TTS model to use. Options:
bulbul:v2, bulbul:v3-beta, bulbul:v3.Speaker voice ID. If
None, uses the model-appropriate default (anushka for v2, shubh for v3).WebSocket URL for the TTS backend.
Buffer text until sentence boundaries before sending.
Audio sample rate in Hz (8000, 16000, 22050, 24000). If
None, uses model-specific default (22050 for v2, 24000 for v3).Runtime-configurable voice and generation settings. See InputParams (WebSocket) below.
SarvamHttpTTSService
Sarvam AI API subscription key.
An aiohttp session for HTTP requests.
TTS model to use. Options:
bulbul:v2, bulbul:v3-beta, bulbul:v3.Speaker voice ID. If
None, uses the model-appropriate default.Sarvam AI API base URL.
Audio sample rate in Hz (8000, 16000, 22050, 24000). If
None, uses model-specific default.Runtime-configurable voice and generation settings. See InputParams (HTTP) below.
InputParams (WebSocket)
| Parameter | Type | Default | Description |
|---|---|---|---|
language | Language | Language.EN | Target language for synthesis. Supports Bengali, English, Gujarati, Hindi, Kannada, Malayalam, Marathi, Odia, Punjabi, Tamil, Telugu. |
pitch | float | 0.0 | Voice pitch adjustment (-0.75 to 0.75). Only for bulbul:v2. |
pace | float | 1.0 | Speech pace multiplier. v2: 0.3-3.0, v3: 0.5-2.0. |
loudness | float | 1.0 | Volume multiplier (0.3 to 3.0). Only for bulbul:v2. |
enable_preprocessing | bool | False | Enable text preprocessing. Always enabled for v3 models. |
min_buffer_size | int | 50 | Minimum characters to buffer before TTS processing. |
max_chunk_length | int | 150 | Maximum characters processed in a single chunk. |
output_audio_codec | str | "linear16" | Audio codec: linear16, mulaw, alaw, opus, flac, aac, wav, mp3. |
output_audio_bitrate | str | "128k" | Audio bitrate: 32k, 64k, 96k, 128k, 192k. |
temperature | float | 0.6 | Output randomness for v3 models (0.01-1.0). Ignored for v2. |
InputParams (HTTP)
| Parameter | Type | Default | Description |
|---|---|---|---|
language | Language | Language.EN | Target language for synthesis. |
pitch | float | 0.0 | Voice pitch adjustment (-0.75 to 0.75). Only for bulbul:v2. |
pace | float | 1.0 | Speech pace multiplier. v2: 0.3-3.0, v3: 0.5-2.0. |
loudness | float | 1.0 | Volume multiplier (0.3 to 3.0). Only for bulbul:v2. |
enable_preprocessing | bool | False | Enable text preprocessing. Always enabled for v3 models. |
temperature | float | 0.6 | Output randomness for v3 models (0.01-1.0). Ignored for v2. |
Usage
Basic Setup (WebSocket)
With v3 Model and Temperature Control
HTTP Service
Notes
- Model differences:
bulbul:v2supports pitch and loudness control;bulbul:v3-betaandbulbul:v3add temperature control but do not support pitch or loudness. Setting unsupported parameters for a model will log a warning. - Default speakers vary by model: v2 defaults to
anushka; v3 models default toshubh. - Default sample rates vary by model: v2 defaults to 22050 Hz; v3 models default to 24000 Hz.
- Indian language focus: Sarvam AI specializes in Indian languages, supporting Bengali, English (India), Gujarati, Hindi, Kannada, Malayalam, Marathi, Odia, Punjabi, Tamil, and Telugu.
- Pace ranges differ:
bulbul:v2supports pace from 0.3 to 3.0, while v3 models support 0.5 to 2.0. Values outside the range are clamped automatically.
Event Handlers
Sarvam WebSocket TTS supports the standard service connection events:| Event | Description |
|---|---|
on_connected | Connected to Sarvam WebSocket |
on_disconnected | Disconnected from Sarvam WebSocket |
on_connection_error | WebSocket connection error occurred |