AI Summary: This article is for backend and API integration engineers who want to put Sarvam AI text-to-speech on a live phone call in 2026. Sarvam’s Bulbul v3 model streams audio over WebSocket and supports 8 kHz output, which matches narrowband telephony, but the official docs document no PSTN, SIP, or carrier layer. The developer must supply the telephony transport, the media bridge, and the resampling logic. Teler’s programmable voice API provides the WebSocket media path and call control layer that connects a carrier call to the Sarvam synthesis engine.
Scope: This walkthrough covers streaming synthesized audio from Sarvam AI text-to-speech (Bulbul v3, as documented in September 2026) into a live PSTN call over a WebSocket media bridge. It does not cover SIP-side PBX configuration or Sarvam’s Samvaad managed agent platform.
Quick Answer: Sarvam AI text-to-speech has no built-in phone connectivity. In 2026, you bridge it to a live call by opening a Sarvam WebSocket at wss://api.sarvam.ai/text-to-speech/ws, streaming text in, receiving base64-encoded audio chunks out, decoding them, and injecting the raw PCM into the call media path at 8 kHz using a telephony transport layer such as Teler.
Sarvam AI text-to-speech does not include a phone number, a SIP trunk, or a carrier connection. Getting it onto a live call requires a media bridge that owns the audio path between the PSTN leg and the synthesis engine, and that bridge is the engineering problem this guide solves.
What is Sarvam AI text-to-speech?
Sarvam AI text-to-speech is an API-layer speech synthesis service that converts written text into natural-sounding audio in Indian languages, built for developers shipping voice experiences and AI agents rather than end-user telephony. It sits at the synthesis layer of a voice stack: it takes text in and returns audio out, over either a synchronous REST endpoint or a persistent WebSocket connection. The service does not provision phone numbers, does not handle SIP (Session Initiation Protocol) signalling, and does not connect to the PSTN (Public Switched Telephone Network). A developer who wants to use it on a live call must supply the telephony transport, the media bridge between the call leg and the WebSocket, and any resampling logic the format difference requires.
Why is putting Sarvam AI text-to-speech on a phone call hard?
The core problem is a format and transport mismatch. Sarvam AI text-to-speech defaults to 24 kHz WAV output, while narrowband telephony runs at 8 kHz PCM, the standard defined in ITU-T G.711. If you send 24 kHz audio into a carrier path expecting 8 kHz, the caller hears distorted or sped-up speech. The second problem is latency. A REST call waits for the full utterance to synthesize before returning any audio, which breaks conversational turn-taking on a live call. The third problem is that the telephony layer does not speak WebSocket natively, so you need a process that sits between the two and handles buffering, backpressure, and interruption events.
Sarvam’s own IVR and contact-center guide, updated September 2026, states directly: use the WebSocket transport so the agent starts playing audio before synthesis finishes, and use linear16 at 8 kHz for PSTN legs. REST is suitable for static prompts and pre-generated playback, not for interactive turns.
What does the end-to-end audio path look like?
Before writing any code, map every hop in the media path. Each hop has an owner, a format, and a transport. A mismatch at any hop produces one-way audio, distortion, or clipped syllables.
| Hop | Transport | Format | Owner |
|---|---|---|---|
| Carrier to telephony layer | PSTN / SIP (RFC 3261) | G.711 linear16, 8 kHz | Telephony provider (e.g., Teler) |
| Telephony layer to your server | WebSocket, JSON frames | PCM 8 kHz or 16 kHz, raw bytes | Teler media stream |
| Your server to Sarvam STT | WebSocket (RFC 6455) | JSON text frames carrying text input | Your bridge process |
| Sarvam TTS to your server | WebSocket, JSON frames | Base64-encoded WAV or linear16 chunks | Sarvam API |
| Your server back to telephony layer | WebSocket, JSON frames | PCM 8 kHz, raw bytes | Your bridge process |
| Telephony layer to carrier | PSTN / RTP (RFC 3550) | G.711 linear16, 8 kHz | Telephony provider |
The key insight is that your bridge process owns two WebSocket connections simultaneously: one to the telephony layer and one to Sarvam. It decodes base64 audio from Sarvam, resamples if needed, and writes raw PCM bytes back into the call stream.
Prerequisites
- A Sarvam AI account with an active API key. The key goes in the
api-subscription-keyheader on every request. - A Teler account with a provisioned phone number and a WebSocket media stream endpoint. See the Teler documentation for number provisioning and stream configuration.
- Python 3.10 or later, with the following packages installed:
pip install python-dotenv websockets - A
.envfile containingSARVAM_API_KEYandTELER_API_KEY. - Network reachability from your server to
api.sarvam.aion port 443 and to Teler’s WebSocket endpoint. - A chosen speaker and model combination validated against Sarvam’s speaker list. Speaker availability is model-specific; an unsupported pair causes synthesis to fail at configuration time, not at runtime.
How to implement Sarvam AI text-to-speech on a live call
Step 1: Configure the Sarvam TTS WebSocket connection
Open a persistent WebSocket to Sarvam’s streaming endpoint. Send the configuration frame first, before any text. The target_sample_rate must be 8000 for a PSTN leg; sending 24000 here means you own the resampling step downstream.
import asyncio
import websockets
import json
import base64
SARVAM_WS_URL = "wss://api.sarvam.ai/text-to-speech/ws?model=bulbul:v3"
SARVAM_API_KEY = "your-api-subscription-key"
async def open_sarvam_tts_socket():
headers = {"api-subscription-key": SARVAM_API_KEY}
ws = await websockets.connect(SARVAM_WS_URL, additional_headers=headers)
config = {
"type": "config",
"data": {
"speaker": "shubh",
"language_code": "hi-IN",
"pace": 1.0,
"min_buffer_size": 50,
"max_chunk_length": 200,
"output_audio_codec": "linear16",
"speech_sample_rate": 8000,
},
}
await ws.send(json.dumps(config))
return ws Watch min_buffer_size and max_chunk_length: both are in milliseconds, and setting them too high delays the first audio chunk enough that the caller perceives a dead line.
Step 2: Open the Teler media stream and receive call audio
When a call arrives, Teler sends a WebSocket event to your server. Your server accepts the stream connection and begins receiving JSON audio frames at the configured sample rate. Teler streams at 8 kHz by default, in chunks of 20 to 2000 milliseconds. The default chunk size is 400 ms, but you must send at least 500 ms of audio back per write to avoid choppy playback on the caller’s end.
async def handle_teler_stream(teler_ws, sarvam_ws, llm_response_text):
# Send LLM output text to Sarvam for synthesis
await sarvam_ws.send(json.dumps({"text": llm_response_text}))
# Receive audio chunks from Sarvam and forward to Teler
async for message in sarvam_ws:
data = json.loads(message)
if data.get("type") == "audio":
raw_audio = base64.b64decode(data["data"])
await teler_ws.send(raw_audio) The data[“data”][“audio”] field is base64-encoded. Decode it to get the PCM bytes, then base64-encode them again inside a JSON audio message, because Teler expects a base64 string in audio_b64, not raw bytes
Step 3: Handle barge-in and interruption
When the caller speaks while the agent is talking, you need to stop playback immediately and discard queued audio. Teler’s {"type": "clear"} message flushes all audio queued for playback on the call leg. On the Sarvam side, the docs advise closing the current TTS WebSocket and opening a fresh connection rather than sending a cancellation message, because no cancellation message type is documented for the TTS socket.
async def handle_barge_in(teler_ws, sarvam_ws):
# Flush queued audio on the call leg
await teler_ws.send(json.dumps({"type": "clear"}))
# Close the current Sarvam TTS socket
await sarvam_ws.close()
# Open a fresh Sarvam TTS socket for the next turn
new_sarvam_ws = await open_sarvam_tts_socket()
return new_sarvam_ws The fresh-socket pattern means your bridge must track the active Sarvam connection reference and replace it atomically when a barge-in event arrives from the VAD (voice activity detection) layer.
Step 4: Validate the audio format before injecting into the call
If you requested 8 kHz Linear16 audio from Sarvam, the audio is already in the format Teler plays (16-bit PCM at 8 kHz) and can be forwarded as is. If you requested any other format, resample to 8 kHz PCM before writing to the Teler stream. Sending 24 kHz audio into an 8 kHz carrier path produces audible distortion. The Sarvam REST reference confirms that Bulbul v3 supports 8000, 16000, 22050, and 24000 Hz; the WebSocket streaming endpoint follows the same sample rate options. See the Teler stream configuration reference for t“the exact JSON audio message format the transport layer expects.
The official SDK at sarvamai/sarvam-ai-sdk (last updated April 2026) contains TTS examples and a Sarvam provider for the Vercel AI SDK. It does not include a telephony bridge, but the audio handling patterns in the examples are worth reviewing before writing your own decode loop.
Most teams discover their latency problem is not the model, it is the resampling hop they added between the carrier and the synthesis engine. If you select linear16 at 8 kHz from Sarvam directly, you eliminate that hop entirely and the first audio chunk arrives at the caller before the full utterance finishes synthesizing.
– Subhash Kalluri, Founder & CEO, FreJun
What breaks in production when using Sarvam AI text-to-speech on a call?
| Symptom | Root cause | Fix |
|---|---|---|
| Distorted or sped-up audio on the caller’s end | TTS output at 24 kHz injected into an 8 kHz carrier path without resampling | Set target_sample_rate: 8000 and target_audio_format: linear16 in the Sarvam config frame |
| First audio arrives late; agent feels unresponsive | min_buffer_size too high or max_chunk_length too long | Reduce both values and tune one at a time; keep punctuation in the text to help the model chunk naturally |
| Speech sounds rushed or unnatural | pace or temperature tuned too aggressively, or long LLM output sent as one block | Start at pace=1.0, split LLM output into short conversational sentences before sending to TTS |
| Synthesis fails at startup | Unsupported speaker and model combination | Validate the speaker against the chosen model before deployment; speaker availability is model-specific |
| Turn-taking feels delayed or unreliable | Default VAD turn strategy waits for events Sarvam never emits | Pass explicit turn strategies in Pipecat; enable metrics so timing gaps are visible |
| TTS requests fail outright with no response | Sarvam model overload or full outage (two separate incidents documented in 2025 and 2026) | Implement client-side retry with exponential backoff; build a fallback path before going to production |
The failure that catches most teams is the format mismatch. It is silent during development because most test environments play audio through a browser or speaker that resamples automatically. The problem only surfaces when audio hits a real carrier path. Selecting linear16 at 8 kHz from Sarvam at configuration time is the single highest-leverage fix in this stack.
One honest limitation of Teler worth noting: the transport layer streams at 8 kHz by default, which is correct for PSTN, but if your Sarvam model or speaker sounds noticeably better at 16 kHz and you want to preserve that quality, you must configure Teler to stream at 16 kHz and match the Sarvam output format accordingly. The two settings must be kept in sync manually; there is no automatic negotiation.
Which integration approach is right for your use case?
| Approach | Where media terminates | Latency cost | Operational burden | Best fit |
|---|---|---|---|---|
| WebSocket media bridge (this guide) | Your bridge process | Lowest; streaming starts before synthesis finishes | Custom buffering, backpressure, barge-in logic | Interactive voice agents, conversational turns |
| REST pre-generate then play back | Application server or storage | Higher; full utterance must complete before playback | Simple; no persistent connection to manage | IVR prompts, announcements, non-interactive turns |
| SIP/RTP media server bridge | PBX or media server | Medium; depends on media server processing | High; SIP signalling, RTP jitter handling, media server ops | Call-center architectures with existing PBX infrastructure |
| WebRTC gateway | Browser or edge gateway | Medium; extra media hop through gateway | Medium; NAT traversal, gateway management | Browser-based agents, hybrid human-in-the-loop systems |
For interactive voice agents where the caller expects a response within a natural conversational pause, the WebSocket media bridge is the right choice. If you are building a one-way announcement system or pre-generating audio for a fixed IVR menu, REST is simpler and the latency cost does not matter. The SIP/RTP path makes sense only if you already operate a media server and want to keep Sarvam AI text-to-speech as a drop-in synthesis layer inside an existing call-center stack.
Frequently asked questions
What audio format should I request from Sarvam for a PSTN call?
Request linear16 at 8000 Hz. PSTN narrowband audio follows the G.711 standard at 8 kHz, and selecting linear16 at 8 kHz from Sarvam means the decoded bytes are ready to inject into the carrier path without a resampling step. Bulbul v3 supports 8000, 16000, 22050, and 24000 Hz; the default is 24000 Hz, so you must set target_sample_rate explicitly.
Does Sarvam AI text-to-speech support SIP trunking directly?
No. The Sarvam API docs document no SIP signalling, no PSTN connectivity, and no carrier access. SIP trunking must be handled by a separate telephony layer. Teler provides SIP trunking with credential or IP authentication and IP access control lists, and it exposes the call media as a WebSocket stream your bridge process can consume.
When should I use the REST endpoint instead of the WebSocket?
Use REST when you are pre-generating audio for static prompts, IVR menus, or announcements where the full utterance is known in advance and latency is not a constraint. Use the WebSocket for any interactive turn where the caller is waiting for a response. REST waits for full synthesis before returning audio; the WebSocket streams chunks progressively so playback can begin before synthesis finishes.
What happens if the Sarvam TTS service goes down during a live call?
The call leg stays up but the agent goes silent. Sarvam documented two separate incidents: a full model outage in September 2026 and a TTS overload event in September 2025. Build a fallback path before going to production. At minimum, implement client-side retry with exponential backoff and a pre-generated fallback prompt that plays when synthesis fails, so the caller hears something rather than silence.
How do I handle barge-in when the caller interrupts the agent?
Send {"type": "clear"} to the Teler stream to flush queued audio on the call leg immediately. Then close the active Sarvam TTS WebSocket and open a fresh connection for the next turn. The Sarvam docs do not document a cancellation message type for the TTS socket, so the fresh-connection pattern is the documented approach. Your bridge must replace the Sarvam socket reference atomically when the barge-in event arrives.
What does the developer have to build themselves that Sarvam does not provide?
You must build the telephony transport, the WebSocket media bridge between the call leg and the Sarvam socket, base64 decode logic for every audio chunk, resampling if you do not select 8 kHz output, barge-in handling, jitter buffering for the RTP path, DTMF detection, and call recording. Sarvam provides synthesis only. Teler covers the telephony transport, call control, and media streaming, but the bridge logic between the two is your code.
How does Sarvam AI text-to-speech perform at scale under concurrent call load?
The Sarvam docs do not publish concurrency limits, rate limits, or maximum session counts. The documented incidents show the TTS model has gone into an overloaded state under real traffic. For production deployments handling significant concurrent call volume, implement connection pooling for Sarvam WebSocket sessions, monitor synthesis latency per turn, and have a fallback synthesis path ready. Do not assume the service scales linearly without testing under your expected peak load.
Can I use Sarvam AI text-to-speech with frameworks like Pipecat or LiveKit?
Yes. Pipecat ships a SarvamTTSService and a SarvamHttpTTSService, and LiveKit has a Sarvam TTS plugin. Both use the WebSocket transport internally. If you use Pipecat, the production guide on the Sarvam docs site recommends passing explicit turn strategies rather than relying on defaults, because the default VAD turn strategy waits for events Sarvam never emits. Teler is listed as a compatible voice API for Pipecat in India if you need the telephony layer alongside the synthesis engine.
Getting Sarvam AI text-to-speech onto a live call in 2026
With the WebSocket bridge in place, you can stream Sarvam AI text-to-speech into a live phone call with sub-utterance latency, provided you select linear16 at 8 kHz and keep your buffer settings tight. The decision that matters most is whether to use the WebSocket streaming path or REST: for any interactive turn, streaming is not optional. If your architecture already includes a SIP media server or a WebRTC gateway, the same Sarvam synthesis endpoint works, but the bridge logic changes at the media termination point. For teams building Indian-language voice agents from scratch in 2026, the WebSocket bridge over a programmable telephony layer is the most direct path from text to caller audio. You can explore the Teler programmable voice API and review the top voice API providers for AI agents in India to compare telephony infrastructure options before committing to a stack.