Sarvam AI TTS
The Sarvam AI TTS provider enables your agent to use Sarvam AI's text-to-speech models for generating voice output.
Installation
Install the Sarvam AI-enabled VideoSDK Agents package:
pip install "videosdk-plugins-sarvamai"
Importing
from videosdk.plugins.sarvamai import SarvamAITTS
Authentication
The Sarvam plugin requires a Sarvam API key.
Set SARVAM_API_KEY in your .env file.
Example Usage
from videosdk.plugins.sarvamai import SarvamAITTS
from videosdk.agents import CascadingPipeline
# Initialize the Sarvam AI TTS model
tts = SarvamAITTS(
# When SARVAMAI_API_KEY is set in .env - DON'T pass api_key parameter
api_key="your-sarvam-ai-api-key",
model="bulbul:v2",
speaker="anushka",
target_language_code="en-IN",
pitch=0.0,
pace=1.0,
loudness=1.2
)
# Add tts to cascading pipeline
pipeline = CascadingPipeline(tts=tts)
note
When using .env file for credentials, don't pass them as arguments to model instances or context objects. The SDK automatically reads environment variables, so omit api_key and other credential parameters from your code.
Configuration Options
api_key: (str) Your Sarvam AI API key. Can also be set via theSARVAMAI_API_KEYenvironment variable.model: (str) The Sarvam AI model to use (default:"bulbul:v2").speaker: (str) The speaker voice to use (default:"anushka").target_language_code: (str) The language code for the generated audio (default:"en-IN").pitch: (float) The pitch of the generated audio (default:0.0).pace: (float) The pace or speed of the generated audio (default:1.0).loudness: (float) The loudness of the generated audio (default:1.2).enable_preprocessing: (bool) Whether to enable text preprocessing on the server (default:True).
Additional Resources
The following resources provide more information about using Sarvam AI with VideoSDK Agents SDK.
- Sarvam docs: Sarvam's full docs site.
Got a Question? Ask us on discord

