llm.guideChapter 22Voice Agents

Voice Agents

Latency budgets, turn-taking, barge-in and production realities.

Part 5: Agents. 10 sections, about 20 minutes.

highlow0 s1.02 stime: 102 frames, 100 per second“where is my order”
highlow0 s1.02 stime“where is my order”
Real audio: the phrase “where is my order”, synthesized and drawn as a spectrogram. A grid like this, a hundred columns for each second, is what a speech model reads.

So far every model in this guide has taken text and produced text. Voice adds two conversions, speech to text and text to speech, and a newer kind of model that skips text altogether. It adds very little new theory. What it adds is a deadline: in conversation a pause of one second already feels wrong, and every stage of the pipeline has to fit inside it.

This chapter covers the three kinds of speech model, the two ways to assemble them, and the engineering of latency and turn-taking that decides whether a voice agent feels alive. Its experiment is a small real pipeline: a synthesizer speaks thirty sentences, noise is added, and a recognizer transcribes them.

22.1Two architectures

A cascade of three models, or one model end to end.

You speakTurn detectionSpeech to textLanguage modelText to speechYou hearbarge-in: you talk, it stopsspeech-to-speech: one model replaces the middle three
Figure 22.1 The cascaded pipeline. Three models in series, plus a stage that decides when you have stopped talking, plus a path for interruptions.

The cascade chains three specialists. A speech-to-text model (STT, also called automatic speech recognition) turns audio into words. A language model, with everything from Chapters 11 to 20 attached, decides what to say. A text-to-speech model (TTS) turns the reply into audio. Between the models there is always text.

A speech-to-speech model takes audio in and produces audio out, with no text stage in between. Section 22.4 covers what that gains and what it gives up.

Stage of the cascadeWhat it doesThe failure it contributes
Turn detectionDecides when the user’s turn has endedThe largest single delay, and the rudest failure: cutting the user off
Speech to textAudio to words, streamed as partial results that firm upWrong words, which poison everything after them
Language modelYour whole existing stack: retrieval, tools, harnessEverything from earlier chapters, now with no screen
Text to speechWords to audio, a sentence at a timeDelay before the first sound; unnatural delivery; it cannot speak a table

As of late 2026 the cascade is still the usual choice for business voice agents, and the reasons appear throughout this chapter: text between the stages is where guardrails, logging and evaluation attach.

Common take“A voice agent is speech-to-text, plus my chatbot, plus text-to-speech.”

Sharper take“It’s my chatbot inside a real-time budget. The two hardest parts, knowing when the user has finished and handling interruptions, aren’t in that formula at all.”

22.2Speech recognition

Errors arrive as confident text.

A recognizer does not hear words. It receives a picture of sound like the one at the top of the chapter: the audio is cut into frames of about ten milliseconds, and each frame records how much energy there is at each pitch. An encoder turns that grid into vectors, and a decoder turns the vectors into text, in the same way as section 12.9 described for audio in general. Streaming recognizers emit partial transcripts while the person is still speaking and revise them as more audio arrives.

Quality is measured as word error rate: the share of words that were substituted, dropped or inserted. To see how it behaves, I ran a small pipeline end to end. An open-source synthesizer, eSpeak NG, spoke thirty sentences: twenty everyday requests and ten containing numbers. I added background noise at four levels, and an open-source recognizer, PocketSphinx, transcribed the results.

0%50%100%clean20 dB10 dB5 dB0 dBwords wrongnoise added (lower numbers are noisier)37%59%
0%50%100%clean20 dB10 dB5 dB0 dBwords wrongnoise added (lower numbers are noisier)37%59%
  • everyday sentences
  • sentences with numbers
Figure 22.2 Real measurement. With light noise the recognizer gets 37% of everyday words wrong and 59% of the words in sentences with numbers. Errors climb toward 90% and beyond as noise increases. On perfectly clean synthetic audio it does worse than with light noise.

Be clear about what this is. Both programs are decades-old designs chosen because they run offline on one processor core, and the voice is robotic. Current neural recognizers make errors on a few words in a hundred under good conditions. The absolute numbers here are far worse than anything you would deploy. The shape of the result is what carries over.

  • Noise is what breaks recognition, and real calls have it: traffic, speakerphones, other voices.
  • Numbers and codes are harder than sentences. Ordinary words are helped by context; a digit is not predicted by the digits around it.
  • A mismatch with training conditions hurts. The recognizer did worse on spotless synthetic audio than on slightly noisy audio, most likely because it was built for recordings that always contain some background sound. Accents, microphones and phone lines that differ from the training data have the same effect.

The part that matters most for an agent is what the errors look like when they arrive.

ConditionsWhat was saidWhat the recognizer returned
Clean audiowhere is my orderwe are we order
Clean audiothe code is nine three zero five twoso like three zero five two
Moderate noisemy payment did not go throughmy favorite bit off go through
Moderate noisemy order number is four four seven onemy lord of the movie or fourth and one

Every transcript is a fluent string of real words. Nothing marks it as wrong. A language model handed “my lord of the movie or fourth and one” has no signal that an order number was intended, and will answer something plausible (section 2.9).

Hence the standard defenses. Give the recognizer a list of your product names and terms where it accepts one. Read identifiers back for confirmation: “that’s four, four, seven, one?” Offer the phone keypad for numbers. And never let a transcribed identifier reach a tool with side effects without a confirmation (section 19.4).

Common take“Speech recognition is a solved problem, so the transcript is what the user said.”

Sharper take“The transcript is the recognizer’s best guess, delivered as confident text. On noisy lines and on numbers it is wrong more often, so I confirm anything I’m about to act on.”

22.3Speech synthesis

Easy to make fast, hard to make natural.

Text-to-speech runs the other way: characters in, a waveform out. The synthesizer in my experiment is a rule-based design from an earlier era. It produced 71 seconds of speech in 0.22 seconds of computing, about 320 times faster than real time, and it sounds like a machine. Current neural systems sound close to human, with breath, emphasis and emotion, and need far more computation for each second of audio. That trade, naturalness against compute and delay, is the whole design space of TTS.

Four properties matter for an agent.

  • Time to first audio. The user waits for the first sound, not the last. A streaming synthesizer starts speaking as soon as it has a sentence or a clause, so replies should open with a short sentence.
  • What it is given to say. A synthesizer reads what it receives. Markdown, tables, links and long numbers come out badly or absurdly. The language model must be told to write for the ear: short sentences, numbers as they are spoken, nothing that depends on layout.
  • Pronunciation. Names, product codes and acronyms are where synthesizers stumble. Most accept a pronunciation dictionary or phonetic hints; use them for the terms that matter.
  • Voice. Systems now offer many voices and can copy a voice from a short sample. Copying a real person’s voice requires that person’s consent, and several jurisdictions regulate it (section 22.10).

Common take“We’ll pass the chatbot’s answer to text-to-speech.”

Sharper take“The chatbot’s answer has bullet points, a link and an order number written as digits. I prompt for speech: short opening sentence, spoken numbers, no formatting. And I measure time to first audio, because that’s the wait the user feels.”

22.4Speech-to-speech models

Tone kept, text layer lost.

A speech-to-speech model works on audio tokens directly. Sound is encoded into tokens at a fixed rate, around thirty per second in one documented case, the model predicts the tokens of a reply, and a decoder turns those back into sound. There is no transcript in the middle.

CascadeSpeech to speech
Response delayAbout a second with care (section 22.5)A few hundred milliseconds
Tone, emotion, laughter, hesitationLost at the transcript; the reply is synthesized from words aloneHeard and produced by the model
Interruptions and back-channel soundsEngineered around the pipeline (section 22.6)More natural; some models listen and speak at once
Guardrails and redactionApplied to text between stagesNo text boundary: harder to filter, harder to remove personal data before the model sees it
Choice of componentsAny recognizer, any language model, any voice, swapped independentlyOne model, one vendor
Logs and evaluationA transcript at every stageA transcript must be produced separately, and may not match the audio
CostThree meters, each modestAudio tokens, with the whole conversation re-read each turn, so long calls cost more per minute than short ones

The rule that follows: choose speech to speech when naturalness and speed are the product, as in companions, tutoring and casual assistants. Choose the cascade when correctness, tools, audit and cost control matter, as in support, booking and anything regulated. Hybrids are appearing, with a speech-to-speech model for conversation that hands off to a cascade for transactions.

CascadeAudio inRecognitionspeech to textLLMtext to textSynthesistext to speechAudio outthe text layer: guardrails, redaction, logs; tone is lost hereSpeech to speechAudio inEncoder~30 tokens / sModelaudio tokensDecodertokens to soundAudio outno text in the middle: tone is kept, the filter point is gone
Figure 22.3 Where the text layer disappears. The cascade gives you a place to inspect and filter; speech to speech gives you tone and speed and takes that place away.

Common take“Speech-to-speech is the newer technology, so we should use it.”

Sharper take“It’s faster and it keeps tone. It also removes the text layer where my guardrails, redaction and logs live. For a support line I keep the cascade. For a conversation partner I’d choose the other.”

22.5The latency budget

The constraint that decides the design.

In human conversation the gap between turns is about a fifth of a second. Past roughly one second a pause reads as a fault, and past two seconds people start talking again. So there is a hard budget, and it should be written down and spent line by line. A typical one, before and after engineering:

Each stage waits for the one before: 5,200 ms before the reply is heard

Stages overlapped: 970 ms to the first audio

  • waiting to be sure the user has stopped: 800 ms, then 300 ms
  • finishing the transcript, and the network: 300 ms, then 100 ms
  • language model: time to first token: 700 ms, then 300 ms
  • language model: the rest of the answer, or only its first sentence: 3,000 ms, then 150 ms
  • speech synthesis: time to first audio: 400 ms, then 120 ms
Figure 22.4 An illustrative budget in milliseconds, using typical figures. In the first bar each stage waits for the one before it to finish. In the second, the stages overlap and the user hears the first sentence while the rest is still being produced.

Three rules follow from the arithmetic.

  • Turn detection is the largest and cheapest lever. It is a threshold, not a computation. Moving it from 800 to 300 milliseconds buys more than any change of model.
  • Only the start matters. Speech is consumed at about three tokens a second and produced at fifty or more. Once audio is playing, the rest of the answer is generated under cover of what is being said. Time to first token and time to first audio are the numbers to watch (section 11.3).
  • Input length is audible. A long retrieved context or a large tool list adds processing time before the first token. Voice agents run leaner prompts and fewer retrieved passages than their text equivalents, and lean hard on prompt caching (section 11.6).

Common take“To make it faster we need a faster language model.”

Sharper take“First I write out the budget. Usually the biggest line is how long we wait to be sure the user has stopped, and the second is waiting for the whole answer before speaking any of it. Neither is fixed by a faster model.”

22.6Turn-taking and barge-in

When to speak, and what to do when interrupted.

Two problems here have no equivalent in text.

Deciding that the user has finished. A fixed silence threshold is wrong in both directions. A short one cuts off anyone who pauses to think: “my order number is… um… four four seven one.” A long one makes every exchange feel dead. The production answer is semantic turn detection: a small fast model, or the recognizer itself, judges whether what has been said is complete. “My order number is” is plainly unfinished. “Where is my order” is done. The wait adapts to the content.

Being interrupted. People talk over each other, and an agent that cannot be interrupted feels like a recording. Handling it, called barge-in, is a cancellation cascade, the discipline of section 19.7 in real time:

GeneratedPlayedUsergenerated, never heard: discard it14 words heardthe user starts speakingbarge-in1 Stop playbackwithin about 100 ms2 Cancel generationstop paying for it3 Tool call in flightcancel or finish it4 Trim the historyto what the user heardHistory written from generated textthe agent “remembers” saying all of it, andlater says “as I mentioned…” about unheard wordsHistory cut at the playback positionthe 14 words that were heard,with the turn marked as interrupted
Figure 22.5 Barge-in as a cancellation cascade. Steps 1 to 3 stop the audio, the spending and any side effect; step 4 keeps the agent’s memory consistent with what the user actually heard.

The fourth step is the one that separates people who have shipped voice from people who have read about it. Suppose the model generated 180 words and playback reached the fourteenth before the interruption. If the full reply is added to the history, the agent now believes it said things the user never heard, and every later turn reasons from that false record: “as I mentioned, your refund is being processed.” It never reached them. The history must be rebuilt from the playback position, not from what was generated.

Common take“When the user interrupts, we stop the audio.”

Sharper take“We stop the audio, cancel generation, deal with any tool call in flight, and trim the history to the words that were actually played. Without the last step the agent remembers a conversation the user didn’t have.”

22.7Overlap everything

Run the stages concurrently, and speak while waiting.

youspeakingspeech to textpartial wordslanguage modelreads aheadwritestext to speech12you hearaudioyou stopfirst audio
Figure 22.6 The stages overlapped in time. Work begins on partial words before the user stops, and the first sentence is spoken while later ones are still being written.

The optimized budget of section 22.5 is bought with four techniques.

  • Feed partial transcripts forward. The stable start of the prompt, the system prompt, history and tools, can be processed and cached before the user has finished speaking.
  • Synthesize sentence by sentence. Split the model’s output at sentence boundaries and start speaking the first while the rest is generated.
  • Say something while a tool runs. If a lookup will take a second and a half, say “let me check that for you” at once. People do the same. Keep it honest and varied, or it becomes uncanny.
  • Generate speculatively. Begin answering on a confident partial transcript and discard the work if the final one differs. This costs tokens to save milliseconds, and is worth it only where the budget is desperate.

Every one of these spends tokens or complexity to buy time. It is the same ledger as elsewhere in this guide, with a much tighter deadline.

Common take“Each stage runs when the previous one has finished.”

Sharper take“Each stage starts as soon as it has anything to work on. The model reads ahead on partial words, the voice starts on the first sentence, and a tool call is covered by a spoken line. That’s where the missing four seconds go.”

22.8Transport and frameworks

Browsers, phone lines and the frameworks that join them.

Audio has to travel both ways continuously, and how it travels sets a floor under everything else.

WebRTC: apps and browsersTelephony: phone numbers and SIP
Delay addedLow: built for real-time mediaTypically 200 to 400 ms more, before any processing
Audio qualityWideband: the full range of the voiceOften narrowband, 8 kHz, which costs recognition accuracy
ExtrasEcho cancellation and noise handling in the clientKeypad tones, call transfer, caller identity, carrier rules
ReachesPeople using your app or siteAnyone with a phone

A phone line therefore starts with a third of the budget already spent and with audio that recognizers handle less well, which makes everything in sections 22.5 to 22.7 matter more.

Few teams assemble the plumbing themselves. Open-source frameworks such as LiveKit Agents and Pipecat provide the real-time loop: transport, turn detection, interruption handling, and connectors for many recognizers, language models and voices, in cascaded or speech-to-speech form. Managed platforms offer the same as a hosted service with phone numbers attached. The trade is the one from Chapter 21. A framework gets a call working in a day, and the details that decide quality, the turn-detection settings, the interruption logic and the handling of history, are defaults that you still need to understand and measure.

Common take“It works well in the browser demo, so the phone version will be the same.”

Sharper take“The phone network adds a few hundred milliseconds and narrows the audio. I test on real phone calls, and I expect to retune turn detection and to confirm more of what the recognizer hears.”

22.9Production realities

No screen, misheard words, and silence.

RealityMechanismDesign response
Recognition errors flow downstreamThe language model receives a wrong string with no sign of uncertaintyVocabulary hints, read-back confirmation, keypad entry, a gate before any action (section 22.2)
There is no visual channelA listener can hold about three options in mind, and cannot see a list, a link or a sourceOne question per turn, at most three options, short sentences. Grounding matters more, since the user cannot check a citation
A turn that calls a tool produces no speechThe model’s output is a tool call, so there is nothing to sayA spoken line while the tool runs. Silence is the worst failure in voice
Cost is per minuteRecognition, model and synthesis each bill for the duration of the callThe levers of Chapter 28 apply, but delay usually outranks cost: a cheaper model that adds 400 ms can lose more than it saves
People say things they would not typeCard numbers, addresses and health details are spoken aloud and recordedRedact transcripts and recordings; pause recording for payment details; retention limits (section 22.10)

Voice changes the deadline and removes the screen. Everything from earlier chapters still applies: grounding, harness, guardrails, routing, caching. What is new is that delay becomes a matter of correctness, since a three-second pause is a failed turn even when the answer is perfect, and that the transcript is something you reconstruct and cannot simply trust.

Common take“The answer was correct. It just took three seconds.”

Sharper take“In voice, three seconds of silence is a wrong answer. The caller has already said ‘hello?’ and started again. I treat latency as part of correctness here.”

22.10Consent and evaluation

Recording rules, disclosure, and tests with audio in them.

Consent and disclosure. A voice agent records and processes speech, and often places or receives phone calls. Each of those is regulated, differently in different places. This is orientation and not legal advice.

  • Recording. In the United States, federal law and most states allow a call to be recorded when one party consents, while a number of states require the consent of everyone on the call. A service that takes calls from anywhere usually announces the recording to every caller for that reason. In Europe a recording of a voice is personal data, so it needs a lawful basis, a notice and a retention limit.
  • Saying that it is an AI. The European Union’s AI Act requires that people be told when they are interacting with an AI system, and United States regulators have ruled that calls using AI-generated voices fall under the rules on artificial voices, which require consent for many outbound calls. Disclosing at the start of the call is the safe default everywhere.
  • Voices. Cloning a real person’s voice needs their permission, and a voice used to identify someone is biometric data in many jurisdictions.

Evaluation. A test set made of text misses most of what goes wrong in voice: recognition errors, premature cut-offs, interruption bugs and delay. Voice needs audio in the loop.

What to testHow
Recognition on your own vocabularyWord error rate on recordings containing your product names, codes and typical accents, at realistic noise levels
DelayTime from the end of the user’s speech to the first audio, per turn, reported as median and 95th percentile, on the real transport
Turn-takingHow often a user who pauses mid-sentence is cut off, and how long the agent waits after a finished one
InterruptionsTime for playback to stop, and whether the history afterward matches what was played
Task successThe final state: was the right appointment booked? (Chapter 23)
SpeakabilityNo formatting, links or raw digit strings in what is sent to the synthesizer

The practical way to run such tests at scale is a synthetic caller: a script whose lines are spoken by a synthesizer, with noise, accents, pauses and interruptions injected, played into the agent over the real transport. The experiment in section 22.2 is that idea at its smallest. Synthetic callers catch regressions. They do not replace listening to real calls, which is still where the surprising failures are found.

Common take“We evaluate the voice agent with our chatbot test set.”

Sharper take“That tests the middle of the pipeline. I add audio fixtures with noise, pauses and interruptions, measure delay per turn on a real phone line, and listen to a sample of real calls every week.”

Key takeaways

  • A voice agent is either a cascade of speech-to-text, a language model and text-to-speech, or one speech-to-speech model.
  • Recognition errors arrive as fluent, confident text. In a small real pipeline, light noise gave 37% word errors on everyday sentences and 59% on sentences with numbers, with far older technology than you would deploy.
  • Confirm identifiers before acting on them.
  • Synthesis is judged by time to first audio and by what it is given to say: write replies for the ear.
  • Speech to speech is faster and keeps tone. The cascade keeps a text layer for guardrails, logs and evaluation.
  • Write the latency budget down. Turn detection is usually the largest line and the cheapest to change.
  • After an interruption, cut the history back to what the user actually heard.
  • Overlap the stages: read ahead on partial words, speak the first sentence early, cover tool calls with a spoken line.
  • Phone lines add a few hundred milliseconds and narrow the audio. Test on the real transport.
  • Announce recording, say that it is an AI, and evaluate with audio in the loop.

Check your understanding

  1. Callers say your voice agent is slow. The language model’s time to first token is 350 ms and its generation speed is normal. Write out where the rest of a three-second delay could be, and what you would change first.

    Answer outline

    List the lines of the budget: the wait to decide that the caller has stopped, often 700 ms or more with a fixed threshold; finalizing the transcript; network and, on a phone line, 200 to 400 ms of transport; waiting for the whole reply before synthesis starts; and the synthesizer’s own time to first audio. Measure each one per turn. Change turn detection first, to a semantic detector with a shorter wait, since it is the largest line and needs no new model. Then synthesize sentence by sentence, shorten the prompt and cache its prefix, and cover tool calls with a spoken line.

  2. After being interrupted, your agent sometimes says “as I already explained” about something the caller never heard, and callers become confused. Explain the bug and the fix, and say how you would test for it.

    Answer outline

    The conversation history is being written from the text the model generated, not from the audio that was played. When playback is cut off after a few words, the rest of the reply is still in the history, so the model believes it was said. Fix: track the playback position, truncate the stored reply to the words actually played, and mark the turn as interrupted. Test with a synthetic caller that interrupts at controlled points, then assert that the stored history matches the played audio and that the next reply does not refer to unplayed content.

  3. You are choosing between a cascade and a speech-to-speech model for two products: a bank’s phone line for account changes, and a language-practice partner for learners. Choose for each and give the deciding properties.

    Answer outline

    The bank line: a cascade. It needs a text boundary for redacting personal data and applying guardrails, a transcript for audit, reliable tool calls with confirmation of identifiers, and control over cost; a response in about a second is acceptable. The practice partner: speech to speech. Its product is natural conversation, so low delay, natural interruption and hearing the learner’s pronunciation and hesitation matter most, and the consequences of an error are small. For both: announce recording and that it is an AI, and evaluate with audio.

Further reading

  • Jurafsky and Martin, Speech and Language Processing: the chapters on automatic speech recognition and text to speech.
  • Philip Kiely, Inference Engineering: the chapter on serving speech and other modalities.
  • The LiveKit Agents and Pipecat documentation: both describe turn detection, interruption handling and pipeline assembly in practical detail.

↑↓ to move↵ to openesc to close