Lesson 8.3 · 3 of 9 · 4 min read · Reviewed 24 Nov 2026
Realtime voice agents: turn-taking and latency
By the end, you can
- Explain turn-taking and latency in realtime voice agents.
- Design for interruptions.
Why latency matters
In conversation, people expect a reply within about a second. Longer gaps feel like the line dropped.
user stops speaking
|-- end-of-turn detection (how long a pause means "done"?)
|-- STT final text
|-- model first tokens (streaming)
|-- TTS first audio (streaming)
v
assistant starts speaking
StreamStreaming: Receiving a response as a series of server-sent events while it is generated, instead of waiting for the whole reply. each stage into the next, rather than waiting for each to finish.
Turn-taking
- End-of-turn detection: too eager cuts users off mid-thought; too slow adds lag. Voice activity detection plus a short silence threshold is common; smarter detectors use the words too.
- Barge-in: when the user speaks over the assistant, stop playback, cancel the rest of the reply, and listen.
- Backchannels: “mm-hm” from the user shouldn’t count as a new turn.
Two architectures
| Cascaded (STT, LLM, TTS) | Speech-to-speech model | |
|---|---|---|
| Latency | Higher, but can be low with streaming | Lowest |
| Control | Full text at each stage; easy to log and filter | Less visibility |
| Tools and guardrails | Same as text agents | Depends on the platform |
| Voice nuance | Lost in transcription | Tone and emotion preserved |
Tools during calls
Tool calls add delay. Say something short first (“Let me check that”), run the tool, then answer.
Key points
- Realtime voice needs low latency: long pauses feel broken, so every stage streams.
- Turn-taking means detecting when the user has finished speaking, and handling interruptions (barge-in).
- Speech-to-speech models handle audio directly; cascaded pipelines are easier to control and inspect.
Budget the latency of one voice turn
Work out how long a caller waits for the first sound, sequential versus streaming, and with a tool call covered by a filler phrase.
You will have: A latency budget for three designs, with time to first audio in milliseconds and a pass or fail against a 1,200 ms target.
Steps
- Run the starter: it prints the stage timings only.
- Fill in sequential(): every stage waits for the previous one to finish completely.
- Fill in streaming(): each stage starts on the first output of the one before.
- Fill in with_tool(): the model says a short filler first, so the caller hears audio before the tool returns.
- Print time to first audio for each design and whether it meets the 1,200 ms target.
Done when
- Sequential prints 3,500 ms and fails.
- Streaming prints 1,100 ms and passes.
- With a filler phrase, the tool design still passes.
Open in the Playground No API key needed.
Starter code (Python)
# Illustrative timings in ms
EOT = 500 # end-of-turn silence threshold
STT_FINAL = 400 # final transcript after turn ends (sequential)
STT_STREAM = 150 # extra wait for the final transcript when streaming
MODEL_FULL = 1800 # whole reply
MODEL_FIRST = 300 # first sentence
TTS_FULL = 800 # whole reply to audio
TTS_FIRST = 150 # first audio chunk
TOOL = 1400 # order lookup
TARGET = 1200
def sequential():
return 0 # TODO: EOT + STT_FINAL + MODEL_FULL + TTS_FULL
def streaming():
return 0 # TODO: EOT + STT_STREAM + MODEL_FIRST + TTS_FIRST
def with_tool():
return 0 # TODO: the filler is the first sentence, so the tool time is not on the path to first audio
for name, f in [("sequential", sequential), ("streaming", streaming), ("tool + filler", with_tool)]:
print(name, f())
Show a solution
EOT = 500
STT_FINAL = 400
STT_STREAM = 150
MODEL_FULL = 1800
MODEL_FIRST = 300
TTS_FULL = 800
TTS_FIRST = 150
TOOL = 1400
TARGET = 1200
def sequential():
return EOT + STT_FINAL + MODEL_FULL + TTS_FULL
def streaming():
return EOT + STT_STREAM + MODEL_FIRST + TTS_FIRST
def with_tool():
filler_audio = EOT + STT_STREAM + MODEL_FIRST + TTS_FIRST
answer_audio = filler_audio + TOOL + MODEL_FIRST + TTS_FIRST
print(f" (answer itself starts at {answer_audio:,} ms, covered by the filler)")
return filler_audio
for name, f in [("sequential", sequential), ("streaming", streaming), ("tool + filler", with_tool)]:
ms = f()
print(f"{name:14} first audio at {ms:,} ms: {'PASS' if ms <= TARGET else 'FAIL'}")