Skip to content

Voice agents

Chapter 12 0 code blocks 222 words

A voice agent on a phone call

Say this

Telephony (SIP or Twilio) streams the call audio to the server. Voice activity detection finds when the caller speaks and stops. Streaming speech-to-text, then the LLM with RAG and tools streaming its reply, then streaming text-to-speech that starts speaking the first sentence early. The hard parts are latency (under about a second per turn) and barge-in: when the caller interrupts, stop speaking at once.

One turn
CallerSIP / TwilioAudio streamVAD + turn detectionStreaming STTLLM+ my RAG, toolsStreaming TTSCaller
Barge-in
Caller speaksStop TTSCancel the LLMListen
the caller speaks while the agent is talking

If they push

  • Rough budget: STT about 300 ms, LLM first token about 300 ms, TTS first audio about 150 ms. Everything streams.
  • Phone audio is 8 kHz, and Uzbek STT is weaker than English, so test it first.
  • Keep spoken answers to one or two sentences. Hand off with a transfer tool and a summary.
  • Frameworks: LiveKit Agents, Pipecat. Speech-to-speech realtime models are faster but give less control.

Be honest

"I haven't shipped a voice agent. My RAG and tool layers are the brain it needs. I'd add streaming STT and TTS around them and measure latency per stage."

Questions about this chapter?

The course, homework review and the other five books are in Uzbek. Questions in English are welcome on Telegram.

Write on Telegram Contents