Design a Real-Time Voice Assistant
Understanding the Problem
🎙️ What is a real-time voice assistant? A real-time voice assistant is an AI you talk to out loud and that talks back, in a conversation that flows like one with a person: it answers within about a second, you can interrupt it, and it can do things for you during the call. ChatGPT's voice mode is the consumer version. Voice-agent platforms like Vapi let businesses put the same thing on a phone line to book appointments or answer support calls, and companies like Sesame work on making the speech itself more natural.
The question comes as "design ChatGPT voice mode," "design a Vapi-style voice agent platform," or "design a streaming STT, LLM and TTS pipeline with barge-in." It's one problem. Whether the user is on an app or a phone line, and whether the assistant is general-purpose or a business's receptionist, the hard parts are the same: latency, knowing when the user has finished, handling interruptions, and keeping tens of thousands of stateful audio sessions running. We'll design a platform that serves both an app (WebRTC) and phone calls, and treat "a business configures an agent" as a thin layer on top.
Functional Requirements
Core Requirements
- Users should be able to talk to the assistant in real time from an app, a browser or a phone call, and hear it answer in natural speech.
- The assistant should know when the user has finished speaking, and users should be able to interrupt it mid-sentence (barge-in), at which point it stops and listens.
- The assistant should be able to take actions during the conversation (look up an order, book a slot) through tools.
- Developers should be able to configure a voice agent (instructions, voice, tools) and attach it to a phone number or an app.
Below the line (out of scope)
- Training the speech and language models. We'll use existing streaming STT, LLM and TTS models, hosted or self-served.
- Voice cloning and its consent process.
- Video, screen sharing and multi-party calls.
Non-Functional Requirements
The defining requirement is latency, so pin it down. In natural conversation, the gap between one person stopping and the other starting is typically around 200 ms. Voice assistants can't get that low yet, but past roughly a second the conversation starts to feel like a walkie-talkie.
Core Requirements
- Voice-to-voice latency (from the user stopping speaking to hearing the first audio of the reply) should be under 800 ms at p50 and 1.5 s at p95.
- When the user interrupts, the assistant's audio should stop within about 200 ms.
- The platform should handle 40,000 concurrent conversations at peak.
- A call must not drop because one server fails; a failure should cost at most a second or two of audio.
- Cost per minute of conversation should be tracked and kept low enough for phone-support economics, where a human agent minute costs on the order of a dollar.
Below the line (out of scope)
- Perfect transcription of every accent and noise condition. We'll measure and improve, not guarantee.
- Regulatory compliance for call recording across jurisdictions (we'll note consent and retention).
Start with the latency budget, because it decides the architecture:
| Stage | Typical time |
|---|---|
| Network, client to server (plus jitter buffer) | 30-80 ms |
| Endpointing: deciding the user has stopped | 200-500 ms |
| STT final transcript after the endpoint | 50-150 ms |
| LLM time to first token | 150-400 ms |
| LLM tokens for a first phrase (~10-15 tokens) | 50-150 ms |
| TTS time to first audio | 100-200 ms |
| Network, server to client | 30-80 ms |
| Total | ~600-1,500 ms |
Two things jump out. First, no stage can wait for the previous one to finish completely: STT has to transcribe while the user is talking, the LLM has to start on the final transcript immediately, and TTS has to start speaking the first phrase while the LLM is still writing the rest. Second, endpointing (waiting long enough to be sure the user is done) is the biggest single piece, and it trades directly against interrupting people mid-thought.
And the scale:
- 40,000 concurrent calls with Opus audio at ~32 kbps each way is about 1.3 Gbps in each direction. That's a modest media fleet.
- If a user finishes a turn about every 10 seconds, that's 4,000 LLM calls per second at peak, each latency-critical. Time to first token matters more than throughput here, so these calls need reserved, lightly loaded capacity, not a busy shared pool.
- STT runs on all 40,000 incoming streams all the time. Assuming a GPU handles on the order of a few hundred concurrent streaming sessions, that's a few hundred GPUs for STT alone. TTS runs only while the assistant speaks (maybe 40% of the time), so ~16,000 concurrent TTS streams.
The interesting part of this problem isn't any one model. It's that every component is streaming, every session is stateful for minutes, and the latency budget has almost no slack. Say early that you're designing a pipeline where each stage starts before the previous one ends.