Voice Agent Architecture
“Talking to machines: The end of the Keyboard.”
TL;DR
A voice agent is a six-stage pipeline: AudioIn -> VAD -> STT -> LLM -> TTS -> AudioOut. STT choices range from Whisper (open weights, not built for streaming) to Deepgram Nova-3 (fast streaming at $0.0077/min), while TTS ranges from ElevenLabs (high quality at $0.04 to $0.08 per 1k characters) to Cartesia Sonic (built for low latency). The critical differentiator between a demo and a product is control logic: VAD silence thresholds determine when the agent speaks, barge-in handling with echo cancellation prevents feedback loops, and voice-specific prompting keeps responses conversational. Cost-wise, a 10-minute call ranges from about $0.20 (economy stack) to $0.70 (premium stack) at November 2026 list prices, before telephony and hosting. These components build on the real-time pipeline patterns covered previously, and are typically orchestrated using voice agent frameworks like LiveKit and Pipecat.

1. Introduction: The Universal Interface
Text is an artifact of computing history. Humans don’t text each other when they are in the same room; they talk. It is the highest bandwidth, lowest friction interface we have. Voice Agents represent the Holy Grail of HCI (Human-Computer Interaction): an interface that requires Zero Training, Zero Literacy, and Zero Hands.
However, building a Voice Agent is exponentially harder than a Chatbot.
- Chatbot: User sends text. Wait 5s. Response appears. The user can switch tabs. The interface is “Async”.
- Voicebot: User speaks. Silence. (1s… 2s…) “Why is it silent?” (3s…) “Hello?” The interface is “Sync”.
- Latency Intolerance: In voice, silence is awkward. It feels like the connection dropped. Once gaps stretch past about a second, users start repeating themselves or asking “Hello?”, and the agent’s next reply collides with them.
- Noise: Background chatter, heavy accents, cheap laptop microphones, wind noise.
- The “Double-Speak” Problem: The agent talks over the user, creating a cacophony.
In this deep dive, we will architect the full Voice Pipeline: AudioIn -> VAD -> STT -> LLM -> TTS -> AudioOut. We will explore the vendor landscape, the rigorous cost economics, and the critical control logic that separates a demo from a product.
2. Component 1: The Ears (STT / ASR)
Speech-to-Text (STT) or Automatic Speech Recognition (ASR). This is the foundation. If the agent mishears “Purchase” as “Perch”, the game is over. No amount of LLM intelligence can fix a bad transcript.
2.1 The Models Landscape: A Vendor Battle
There is no “One Model Fits All”. You typically choose between three categories.
A. The Open Source Standard: OpenAI Whisper
- Architecture: Encoder-decoder Transformer, originally trained on 680k hours of weakly supervised audio from the internet (large-v3 added millions of hours of pseudo-labeled audio).
- Pros:
- Accuracy: Strong on English and many other languages, and robust to accents and noise.
- Punctuation: It outputs grammatically correct text with commas and periods (Critical for the LLM to understand meaning).
- Price: Open weights (MIT license). You pay only for the GPUs that run it.
- Cons:
- Speed: It is not a streaming model. It works on 30-second windows, so live use needs chunking workarounds that add latency. Newer open models such as NVIDIA’s Parakeet and Canary families are much faster and score competitively on the Hugging Face Open ASR Leaderboard.
- Hallucinations: In silence, it sometimes hallucinates text like “Thanks for watching” (Subtitle artifacts).
B. The Speed Demon: Deepgram Nova-3
- Architecture: Proprietary E2E Deep Learning.
- Pros:
- Latency: Fast streaming transcription, commonly around 300ms. Deepgram’s Flux model goes further and builds end-of-turn detection into the recognizer for voice agents.
- Cost: Cheap. Pay-as-you-go list price is $0.0077/min streaming and $0.0043/min pre-recorded (Deepgram pricing, November 2026).
- Phone Audio: Widely used on narrowband (8 kHz) telephone audio.
- Cons: Closed source. You are vendor-locked.
C. The Intelligence Layer: AssemblyAI / Rev
- Pros: Strong focus on “Understanding”.
- Speaker Diarization: “Speaker A said X, Speaker B said Y”. (Critical for meeting bots).
- Sentiment Analysis: Returns positive, neutral or negative sentiment per sentence alongside the text.
- PII Redaction: Automatically masks “SSN: 123-45…”.
2.2 Streaming vs Batch: The Latency Choice
- Batch: Record 10s of audio -> Upload -> Transcribe.
- Latency: 10s (Recording) + 2s (Upload/Process) = 12s. Unusable for live conversation.
- Streaming (WebSockets):
- Client opens WebSocket. Sends raw PCM bytes (chunks of 20ms).
- Server processes chunks incrementally.
- Server returns partial transcripts:
("He")->("Hell")->("Hello"). - Latency: < 500ms.
- Mechanism: Use Endpointing. The STT provider usually tells you “I think the utterance is done” with a flag (Deepgram, for example, sets
speech_final=true). This is your trigger to send the text to the LLM.
3. Component 2: The Brain (LLM)
The LLM part is standard (pick a fast, non-reasoning model: time to first token matters more than benchmark rank), but the Prompt Engineering is radically different.
3.1 Voice-Specific Prompting
- Brevity: People read faster than they listen. A 60-word paragraph takes about 15s to read (at ~240 wpm) but about 25s to hear (at ~150 wpm).
- Instruction: “Be concise. Use colloquial language. Do not use lists or bullet points. Avoid markdown.”
- Bad Response: “Here are three reasons: 1. Speed, 2. Cost, 3. Quality.” (Sounds robotic).
- Good Response: “Well, it mostly comes down to speed, cost, and quality.” (Sounds natural).
- Filler Words: To mask latency, you can instruct the model or the orchestrator to emit “Fillers” immediately (
"Hmm, let me check...","Okay...","Got it."). - Technique: Optimistic Acknowledge. As soon as STT finishes, play a pre-recorded “Sure!” sound file from the client cache while the server thinks. This hides a few hundred milliseconds of thinking time.
4. Component 3: The Mouth (TTS)
Text-to-Speech (TTS). The voice is the brand.
- ElevenLabs: A common benchmark for quality.
- Quality: Very natural, with emotional range (can whisper, shout, laugh).
- Latency: Its Flash models advertise ~75ms model latency. The more expressive multilingual models are slower.
- Cost: $0.04 per 1k characters (Flash/Turbo) to $0.08 (Multilingual v2/v3) on the API (ElevenLabs API pricing, November 2026).
- OpenAI TTS (tts-1): Good quality, highly consistent.
- Latency: Fast enough for conversation.
- Cost: Cheap ($15 per 1M characters, i.e. $0.015 / 1k chars).
- Sound: Less expressive than ElevenLabs.
- Cartesia (Sonic): Built for speed.
- Latency: Very low time to first audio, which is its main selling point.
- Usage: Real-time conversational agents where snappy turns matter more than perfect “Radio DJ” voice.
Vendors in this layer change quickly: PlayHT, once a common pick, was acquired by Meta in 2025 and its API was wound down. Keep TTS behind an interface you can swap. For how to compare latency claims, see the sub-100ms TTS race; for when running your own model pays off, see self-hosted TTS economics.
Streaming TTS: You must stream the audio back. Playing it all at once adds seconds of delay. The TTS engine should yield MP3/PCM chunks as soon as it generates them.
5. The Critical Control Logic: VAD and Barge-In
This is where most amateur voice agents fail. The ability to handle “Silence” and “Interruption” determines if the user feels listened to.
5.1 Voice Activity Detection (VAD)
How does the agent know you finished your sentence?
- Human: “I want a burger…” (Pause 500ms) “…and fries.”
- Bad Agent: Hears “burger”. Interrupts: “What kind of burger?”
- Human: “…and fries. Shut up.”
The Silence Timeout: We configure a VAD threshold (e.g., 700ms of silence). If silence > 700ms, we assume the turn is over.
- Trade-off:
- Short Timeout (300ms): Snappy, but interrupts mid-thought.
- Long Timeout (1000ms): Polite, but feels sluggish. The agent seems “Slow”.
- Adaptive Timeout: Use a fast LLM to predict if the sentence is complete (“I want a…” -> Incomplete. “I want a burger.” -> Complete). If incomplete, extend timeout.
5.2 Barge-In (Interruption)
If the Agent is speaking, and the User starts speaking, the Agent MUST stop immediately. This requires a complex state transition and robust Echo Cancellation.
The Echo Cancellation (AEC) Problem
If you play sound out of the speakers, the microphone picks it up. Without AEC, the Agent hears its own voice loop back into the mic.
- Agent says “Hello”.
- Mic hears “Hello”.
- VAD detects speech.
- Agent thinks User spoke.
- Agent interrupts itself to listen.
- Result: A feedback loop where the agent keeps interrupting itself.
- Solution: WebRTC has built-in AEC. If building raw Python pipelines, you need libraries like
speexdspor hardware DSP.
- Solution: WebRTC has built-in AEC. If building raw Python pipelines, you need libraries like
The Interrupt Protocol
- Trigger: VAD detects speech energy while
AgentState == SPEAKING. - Action 1 (Network): Send
CLEARpacket to client. Client immediately wipes its Audio Buffer (stops playing). - Action 2 (Backend): Kill the LLM generation task (stop paying for tokens). Kill the TTS generation task.
- Action 3 (State): Transition
AgentStatetoLISTENING. Keep only the part of the reply the user actually heard in the conversation history, and discard what the agent was about to say.
6. Architecture Diagram
The flow of data is a Figure-8 loop.
sequenceDiagram
participant User
participant VAD
participant STT
participant LLM
participant TTS
participant AudioPlayer
User->>VAD: Audio Stream
VAD->>STT: Speech Frames
STT->>LLM: "Hello"
LLM->>TTS: "Hi there" (Stream)
TTS->>AudioPlayer: Audio Bytes
AudioPlayer->>User: Sound ("Hi there...")
Note right of User: User Interrupts! "Wait!"
User->>VAD: "Wait!" (Energy Spike)
VAD->>AudioPlayer: STOP COMMAND (Clear Buffer)
AudioPlayer-->>User: (Silence)
VAD->>STT: "Wait!"
STT->>LLM: "Wait!"
7. Cost Analysis: The Economics of Voice
Voice is expensive compared with text chat. Let’s do the math for a 10-minute active conversation, using pay-as-you-go list prices checked in November 2026 (they change often, so rerun this with your own numbers).
Assumptions: STT streams all 10 minutes of audio. The agent talks about half the time: 5 minutes at ~150 wpm is ~750 words, or ~4,500 characters of TTS. There are ~40 LLM turns (4 per minute), each resending ~3,000 input tokens (system prompt, tools, history) and producing ~50 output tokens.
7.1 Premium Stack (Deepgram Nova-3 + GPT-4.1 + ElevenLabs Multilingual)
- STT (Deepgram Nova-3, streaming): $0.0077 / min. (10 mins = $0.077).
- LLM (GPT-4.1, $2 / $8 per 1M input/output tokens): ~$0.0064 / turn. (40 turns = $0.26).
- TTS (ElevenLabs Multilingual, $0.08 / 1k chars): 4.5k chars = $0.36.
- Total: ~$0.70 per call.
- Viability: Fine for most business use cases; at scale, TTS is the line item to attack first.
7.2 Economy Stack (Deepgram Nova-3 + GPT-4.1-mini + OpenAI TTS)
- STT (Deepgram Nova-3): $0.077.
- LLM (GPT-4.1-mini, $0.40 / $1.60 per 1M tokens): ~$0.0013 / turn. (40 turns = $0.05).
- TTS (OpenAI tts-1, $0.015 / 1k chars): 4.5k chars = $0.07.
- Total: ~$0.20 per call.
- Viability: Viable for Customer Support, Ordering, consumer apps.
Neither total includes telephony (a US phone number adds roughly $0.01/min with providers such as Twilio), your own hosting, or a platform fee if you use a hosted voice-agent service. Prompt caching can cut the LLM line substantially, because most of each turn’s input is a repeated prefix.
Business Model: You generally cannot offer free unlimited voice agents. You need a subscription (SaaS) or usage caps (Credits).
8. Summary
Voice Agents are a distributed systems problem wrapped in a UX problem.
- STT/TTS Latency dominates the first impression.
- VAD tuning is the difference between “Smart” and “Annoying”.
- Barge-In requires rigorous state management to prevent feedback loops.
- Cost requires careful model selection.
- Security gets new attack paths once the agent answers the phone; see security for voicebots.
To manage this complexity, we often rely on dedicated Voice Agent Frameworks like LiveKit and Pipecat that abstract away the plumbing of WebRTC and VAD.
FAQ
Q: What components make up a voice agent architecture? A: A voice agent pipeline consists of six stages: AudioIn (microphone capture), VAD (voice activity detection to detect speech boundaries), STT (speech-to-text transcription), LLM (language model for reasoning), TTS (text-to-speech synthesis), and AudioOut (speaker playback). Each stage streams data to the next for low latency.
Q: How much does it cost to run a voice agent per call? A: At list prices checked in November 2026, a 10-minute call costs roughly $0.70 on a premium stack (Deepgram Nova-3, GPT-4.1, ElevenLabs Multilingual) and about $0.20 on an economy stack (Deepgram Nova-3, GPT-4.1-mini, OpenAI tts-1), before telephony and hosting. TTS and LLM are the biggest cost drivers, and LLM cost grows with the context you resend every turn.
Q: What is barge-in and why is it important for voice agents? A: Barge-in is the ability for a user to interrupt the agent while it is speaking. It requires the agent to immediately stop TTS playback, cancel LLM generation, clear audio buffers, and transition to a listening state. Without it, the agent talks over the user, breaking conversational flow.
Q: How does echo cancellation work in voice agents? A: Echo cancellation prevents the agent from hearing its own voice played through the speakers via the microphone. Without it, the agent detects its own speech as user input, creating a feedback loop where it interrupts itself endlessly. WebRTC provides built-in AEC, or you can use libraries like speexdsp.