KatInterview

Streaming Voice Agent Architecture with Barge-In Support

System DesignModel answer
MediumModel answerSystem Designreal-timestreaminglatency

Last updated

Design the backend for a conversational voice agent that listens, reasons and speaks in near real time, serves thousands of simultaneous callers, and handles users cutting in mid-reply.

Build a Voice Agent Backend

You are asked to design the infrastructure for a spoken conversational assistant. A user talks into a browser, phone app or telephone line. The assistant must understand the speech, decide on a reply with a language model, and speak that reply back, all fast enough that the exchange feels like a natural conversation (roughly half a second from the moment the user stops talking to the moment they hear the assistant).

What the system must do

  • Detect speech boundaries. Work out when the user begins and finishes speaking.
  • Transcribe. Convert the incoming audio stream to text as it arrives.
  • Decide and respond. Interpret the request and produce a reply using a language model.
  • Speak. Turn the reply text into audio and play it to the user.
  • Handle interruptions. If the user starts talking while the assistant is still speaking, playback must stop right away and the system should react sensibly.

Qualities it must have

  • Latency: responses must feel conversational.
  • Scale: thousands of simultaneous sessions.
  • Memory: the assistant keeps context across turns.

Assumptions

  • A streaming language model API already exists and can be called as a black box.
  • Your job is the infrastructure that connects the speech components, the model and the clients.

What to cover in your answer

  1. A high-level architecture, described in words (components and how they connect).
  2. How data moves through the system, including how audio buffering works.
  3. Your approach to cutting latency across the speech recognition and speech synthesis path.
  4. How the architecture handles a user interrupting ("barge-in").

State any assumptions about scale, latency targets and transport that you make along the way.

Hints

Hint 1

Define latency precisely (end of user speech to first audible audio), then split the target into a per-stage budget and check whether the stages add up. If they do not, you need overlap between stages.

Hint 2

Make every stage streaming and connected by long-lived connections, and consider starting speech synthesis on the first clause of the model output rather than the full reply.

Hint 3

Treat interruption as cancellation that must travel through every stage, fastest at the client. Think about discarding stale audio, and about recording only what the user actually heard in the conversation history.