Topic 2 of 5 · 5 min read
Streaming audio within a latency budget
Goal: Break an end-to-end voice round trip into its stages from a timing log and name the stage that pushes it past its latency budget.
A voice reply is the sum of five delays, so set a budget for the whole round trip, measure each stage, and fix the largest one, not the one you find easiest to tune. People notice a pause in conversation at well under a second.
Check yourself · 1 of 3
What does "time to first audio byte" measure for text-to-speech?
The stages
- Capture and chunking. The microphone audio is cut into chunks, often 20 to 100 ms each. Bigger chunks mean fewer network calls but add their own length to the delay.
- Speech to text. The recogniser returns partial transcripts that keep changing, then a final transcript once it decides the speaker stopped. Waiting for the final result is safe but late.
- End-of-speech detection. A silence timer, such as 700 ms, decides when the user is done. This pause is added to every turn.
- Language model. Time to the first token matters, not total time, if you stream.
- Text to speech. Measure time to first audio byte, then play audio while the rest is still being made.
How to measure
Log a timestamp at each boundary with the same clock and subtract. Do this for many turns and read the median and the slow tail, not one run.
{"turn":14,"t_user_stop":0,"t_final_text":820,"t_llm_first_token":1390,"t_tts_first_byte":1710,"t_audio_playing":1750}
Read it as gaps: 820 ms from the user stopping to the final text, 570 ms to the first model token, 320 ms to first audio, 40 ms to playback. The recogniser stage is largest, and most of it may be the silence timer.
Before and after
Before: the app waits for the final transcript, sends it to the model, waits for the whole answer, then asks TTS for one audio file. Total: 3.4 seconds.
After: the silence timer is cut from 900 to 500 ms, the model streams tokens, TTS starts on the first full sentence and audio plays as it arrives. Total: 1.6 seconds with the same models.
What goes wrong
- Optimising the wrong stage. A faster model saves 100 ms while the silence timer costs 700.
- Cutting the silence timer too far. The assistant now interrupts people who pause to think. Pair it with a smarter turn detector or allow barge-in.
- Using partial text as final. Partials change; acting on one can run a wrong command.
- Averages that hide the tail. A 1.2 s average with a 4 s worst case still feels broken.
Examples
Finding the slow stage in a timing log
{"turn":3,"t_user_stop":0,"t_final_text":1210,"t_llm_first_token":1500,"t_tts_first_byte":1790,"t_audio_playing":1820}
The gaps are 1210, 290, 290 and 30 ms. Recognition and the end-of-speech wait take two thirds of the 1.8 s. Faster text-to-speech cannot fix this turn; check the silence timer and whether the app waits for the final transcript.
Key points
- Set one budget for the whole round trip, then split it across capture, recognition, end-of-speech wait, model and speech output.
- Partial transcripts arrive early and can change; the final transcript is stable but later.
- Time to first audio byte, not the total synthesis time, decides how fast a spoken reply feels.
- Read timing logs as differences between boundaries and look at the slow tail, not only the average.
- Fix the largest stage first, and check that a speed-up does not cause interruptions.
Common mistakes
- Tuning the model or TTS because it is easy to change while the end-of-speech wait is the largest stage.
- Treating a partial transcript as final and acting on it before it settles.
- Cutting the silence timer so far that the assistant talks over people who pause.
- Reporting only the average delay and ignoring slow turns.
Check yourself · 2 of 3
A voice app has a 1.5 s budget. The log shows 300 ms to the final transcript after speech ends, a 900 ms silence timer and 200 ms to first audio. Which stage is the largest?
Check yourself · 3 of 3
Why is it risky to run a command from a partial transcript?
Practice items, not counted towards your mastery.
Start here
- Speech to text guide (OpenAI) (opens in a new tab)DocsFree
Transcription endpoints, file limits, the prompt parameter and timestamps, from one vendor.
- Text to speech guide (OpenAI API) (opens in a new tab)DocsFree
Stock voices, streaming audio output, style instructions and the disclosure requirement.
- Hugging Face Audio Course (opens in a new tab)CourseFree
Free course on audio data, speech recognition and synthesis, with word error rate explained.