Architecting a Sub-300ms Real-Time Voice AI Agent for Telephony: SIP, WebRTC, and Custom VAD
Detailed engineering breakdown of building full-duplex Indic voice callers using Pipecat, Sarvam AI, Exotel WebSockets, and Silero VAD over 8kHz PSTN phone lines with zero platform markups.
Gurdharam Jeet Singh
Founder & Lead AI Architect at Gurdharam AI Engineering. Leading a CS engineering squad building direct Meta Cloud API WhatsApp bots, Indic Voice AI calling agents (Sarvam AI), edge computer vision models (TFLite/Flutter), and 3D WebGL platforms for clients globally.
Turn-Taking Latency Benchmarks
1. The Latency & Turn-Taking Bottleneck
Traditional IVR phone bots and generic voice agents fail in human conversations for one primary reason: latency. When a human speaks on a mobile phone call, an awkward delay of more than 800 milliseconds creates overlapping speech, robotic pauses, and immediate caller frustration.
In the Indian telecommunications landscape, additional constraints complicate execution: 8kHz mu-law audio compression over PSTN networks, high ambient noise in rural calls, and frequent code-switching between English, Hindi, and regional dialects (Hinglish/Punjabi).
To solve this, we engineered a full-duplex streaming voice architecture using Pipecat framework, Sarvam AI Indic STT/TTS, Silero Voice Activity Detection (VAD), and Exotel WebSocket SIP trunking — locked under 290 milliseconds total round-trip latency.
2. Full-Duplex Audio Pipeline Architecture
The continuous audio pipeline pipes 20ms PCM audio chunks bi-directionally over WebSockets:
3. Pipecat Python Pipeline Implementation
Below is the core Python initialization code assembling the audio transport, Silero VAD, and Sarvam AI streaming nodes:
import async_timeout
from pipecat.pipeline.pipeline import Pipeline
from pipecat.pipeline.runner import PipelineRunner
from pipecat.pipeline.task import PipelineTask
from pipecat.transports.network.websocket_server import WebsocketServerTransport
from pipecat.services.sarvam import SarvamSTTService, SarvamTTSService
from pipecat.services.openai import OpenAILLMService
from pipecat.audio.vad.silero import SileroVAD
# 1. Initialize Silero VAD for Instant Interruption Handling
vad = SileroVAD(
sample_rate=8000,
threshold=0.6,
min_speech_duration_ms=100
)
# 2. Exotel / WebSockets Transport Engine
transport = WebsocketServerTransport(
host="0.0.0.0",
port=8765,
vad=vad,
audio_in_sample_rate=8000,
audio_out_sample_rate=8000
)
# 3. Sarvam Indic Speech Services Setup
stt = SarvamSTTService(api_key=SARVAM_API_KEY, model="saaras:v1", language_code="hi-IN")
tts = SarvamTTSService(api_key=SARVAM_API_KEY, speaker="meera", model="bulbul:v1")
llm = OpenAILLMService(base_url="http://localhost:8000/v1", model="Qwen2.5-70B-Instruct")
# 4. Construct Pipecat Task Pipeline
pipeline = Pipeline([
transport.input(), # Receives 8kHz PCM audio from PSTN
stt, # Converts audio to text in ~80ms
llm, # Generates conversational response stream
tts, # Synthesizes Indic audio in ~70ms
transport.output() # Pushes audio stream back to caller
])
# 5. Handle Real-Time User Interruption Event
@transport.event_handler("on_user_started_speaking")
async def handle_interruption(transport, frame):
print("User interrupted AI speaker! Cancelling active TTS queue...")
await tts.cancel_active_speech()4. Latency Breakdown Comparison
| Pipeline Stage | Generic Cloud Voice Bot | Our Sarvam Engine | Latency Win |
|---|---|---|---|
| Speech Recognition (STT) | 250 ms | 80 ms (Saaras) | 3.1x faster |
| LLM Time To First Token | 450 ms | 120 ms (vLLM) | 3.7x faster |
| Text-to-Speech (TTS) | 220 ms | 70 ms (Bulbul) | 3.1x faster |
| Total Turn-Taking Latency | 980 ms (Unnatural) | 285 ms (Human-like) | 3.4x lower delay |
Frequently Asked Questions
How does the voice agent handle heavy Indian background noise (traffic, crowds, wind)?
We integrate DeepFilterNet WebAssembly noise suppression alongside Silero VAD, filtering out 98% of background environmental noise before sending audio tensors to the STT model.
Can the voice AI transfer live calls to a human agent if an emergency occurs?
Yes. When sentiment or explicit trigger keywords are detected, the system executes an instant SIP REFER call transfer payload to route the PSTN call to a human call center agent in under 2 seconds.
Deploy Sub-300ms Indic Voice AI Telephony
Automate inbound support, outbound lead calls, and debt collection with human-like, ultra-fast Voice AI agents today.
Consult Voice AI Engineer