Sarvam AI TTS
The SarvamTTSService provides high-quality speech synthesis for Indian languages. It supports multiple regional languages and offers both WebSocket-based streaming and standard HTTP interfaces.
Installation
To use Sarvam AI, install the required dependencies:
pip install "piopiy-ai[sarvam]"
Prerequisites
- A Sarvam AI API key (Get yours here).
- Set your API key in your environment:
export SARVAM_API_KEY="your_api_key_here"
Configuration
SarvamTTSService (WebSocket) Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | Required | Your Sarvam AI API key. |
voice_id | str | "anushka" | Speaker voice ID (see below). |
model | str | "bulbul:v2" | Model ID (bulbul:v2, bulbul:v3). |
params | InputParams | None | Configuration parameters (see below). |
InputParams Options
| Option | Type | Default | Description |
|---|---|---|---|
language | Language | Language.EN | Target language (e.g., Language.HI). |
pitch | float | 0.0 | Voice pitch adjustment (-0.75 to 0.75). |
pace | float | 1.0 | Speech pace multiplier (0.3 to 3.0). |
loudness | float | 1.0 | Volume multiplier (0.1 to 3.0). |
temperature | float | 0.6 | Randomness for v3 models (0.01 to 1.0). |
Usage
Basic Streaming Setup
import os
from piopiy.services.sarvam.tts import SarvamTTSService
from piopiy.transcriptions.language import Language
tts = SarvamTTSService(
api_key=os.getenv("SARVAM_API_KEY"),
voice_id="anushka",
params=SarvamTTSService.InputParams(
language=Language.HI # Hindi
)
)
Available Voices
| Gender | Voice IDs |
|---|---|
| Female | anushka, manisha, vidya, arya |
| Male | abhilash, karun, hitesh |
Notes
- Language Support: Sarvam supports Bengali, English (India), Gujarati, Hindi, Kannada, Malayalam, Marathi, Odia, Punjabi, Tamil, and Telugu.
- Model Versions:
bulbul:v2is the stable standard, whilebulbul:v3offers enhanced naturalness and lower latency.