Skip to main content

Featured

Free Text-to-Speech for YouTube Videos: My Kokoro TTS Pipeline

Every tutorial and Short on my YouTube channel Omilabs is narrated by a synthetic voice. I don't record my own voiceover for these videos. The narration comes from a script that turns each line of text into audio, and that script runs on Kokoro, a small open-weight text-to-speech model. In this post I explain how I set it up, the problems I hit, and the checks I now run so the voice sounds clean and stays consistent across more than a hundred videos. Why I Picked an Open TTS Model When you make one video, a paid voice tool is easy. When you make a full series of long episodes plus many Shorts, and you rebuild the audio every time a script line changes, a few things start to matter more: Re-runs cost nothing. I edit scripts often. With a local model I can regenerate a whole episode as many times as I want. It runs anywhere. The model is small enough to run on a normal CPU, including a free GitHub Actions runner, which is where my videos are rendered now. The output is rep...

How to Reduce Latency in AI Voice Agents: A Practical Checklist

Anyone who has called an AI voice agent knows the moment that breaks the illusion: you finish your sentence, and there is a pause. Half a second feels natural. Two seconds feels like the line dropped. Most callers will start talking again, the agent will interrupt them, and the conversation falls apart. In voice AI, latency is not a technical detail. It is the user experience.

This guide explains where the delay in a voice agent actually comes from and gives a practical checklist to reduce it. It applies whichever platform you use, because every voice agent is built from the same basic pipeline.

Where the delay comes from

A typical voice agent turn has five stages. Each one adds time, and the caller feels the total.

  1. Endpointing. The system has to decide that the caller has finished speaking. It usually waits for a short stretch of silence before it acts. If that silence threshold is long, every single turn starts late.
  2. Speech-to-text (STT). The caller's audio is converted to text. Streaming STT produces partial text while the person is still talking; batch STT waits for the whole utterance.
  3. The language model (LLM). The text goes to the model with your system prompt and the conversation history. What matters here is not the total generation time but the time to first token: how quickly the model starts producing its answer.
  4. Text-to-speech (TTS). The answer is turned into audio. Streaming TTS can start speaking the first sentence while the rest is still being generated.
  5. Network and telephony. Audio travels between the phone network, your telephony provider and every API in the chain. Each hop between regions adds delay.

The important insight is that these stages can either run one after another or overlap. A slow agent waits for each stage to finish completely. A fast agent streams: it starts the next stage as soon as the previous one has produced enough to work with.

Step 1: Measure before you change anything

Do not guess where the time goes. Make ten test calls and, for each turn, note:

  • When the caller stopped speaking.
  • When the final transcript arrived.
  • When the first LLM token arrived.
  • When the first audio byte of the reply was played.

Most platforms show per-turn timings in their call logs or traces. If yours does not, record the call and measure the gap between the end of the caller's sentence and the start of the agent's reply. The median of those gaps is your real number. Fix the largest stage first; shaving time off a stage that is already fast changes nothing the caller can hear.

Step 2: Tune endpointing carefully

The silence threshold is often the single biggest and cheapest win. If the agent waits a full second of silence before responding, no amount of model optimisation will make it feel fast.

But endpointing is a trade-off. Too short, and the agent interrupts people who pause to think, read out a number or search for a word. A good approach:

  • Lower the threshold in small steps and listen to real calls after each change.
  • Use a longer threshold for turns where the caller is expected to give long or structured answers, such as an address or an account number, if your platform supports per-step settings.
  • Enable interruption handling (often called barge-in) so that if the agent does start talking too early, it stops as soon as the caller continues.

Step 3: Use streaming everywhere

Check each component of your pipeline and confirm it is running in streaming mode:

  • Streaming STT so the transcript is nearly ready the moment the caller stops.
  • Streaming LLM responses so tokens are passed on as they are generated.
  • Streaming TTS so audio for the first sentence starts playing before the full reply exists.

If any one stage waits for the complete output of the previous one, it becomes the bottleneck for the whole turn.

Step 4: Make the model's job smaller

Time to first token grows with the amount of work the model has to do before it can start. Several things help:

  • Choose a model sized for the task. A voice agent that books appointments or answers order-status questions rarely needs the largest model available. Smaller, faster models are often good enough and respond noticeably quicker. Test quality and speed together, not separately.
  • Keep the system prompt tight. A prompt with pages of rules, examples and edge cases is processed on every single turn. Remove anything that is not needed for the conversation at hand.
  • Ask for short replies. Instruct the agent to answer in one or two sentences. Short replies are faster to generate, faster to speak and easier for callers to follow on the phone.
  • Trim the conversation history on long calls if your platform allows it, keeping the facts that matter rather than every word ever said.

Step 5: Be careful with tool calls

When the agent needs to look something up, such as checking a booking or fetching a customer record, it calls an external API. That call happens in the middle of the turn, and the caller hears silence while it runs.

  • Make the API itself fast. An endpoint that takes two seconds to respond will make the agent feel broken no matter how fast everything else is.
  • Have the agent say a short filler line before slow lookups, such as "Let me check that for you." Silence feels like a failure; a short acknowledgement feels like service.
  • Fetch data you will certainly need at the start of the call, before the conversation reaches that point.

Step 6: Keep everything close together

Every network hop adds delay. If your telephony provider is in one region, your STT in another, your model in a third and your TTS in a fourth, the audio crosses the world several times on every turn. Where your providers let you choose, pick regions close to each other and close to your callers. For businesses calling customers in India, that usually means preferring Indian or nearby regions where they are offered.

Step 7: Choose voices that start quickly

TTS providers often offer several model tiers: some optimised for the highest quality, others optimised for low latency in real-time conversation. For phone calls, the low-latency tier is usually the right choice. Phone audio is compressed anyway, so the difference in quality is much smaller than the difference in responsiveness. Check your provider's documentation for which models are recommended for conversational use.

A quick checklist

  • Measured per-stage timings on at least ten real test calls.
  • Endpointing threshold tuned and tested on real speech, with barge-in enabled.
  • Streaming enabled for STT, LLM and TTS.
  • Model chosen for speed and quality together.
  • System prompt trimmed; replies limited to one or two sentences.
  • Slow tool calls covered by a short spoken acknowledgement.
  • All providers in nearby regions.
  • Low-latency TTS model selected for phone calls.

Final thought

Latency work is never finished in one pass. Every time you change the prompt, add a tool or switch a provider, measure again. The goal is not a perfect number on a dashboard but a conversation where the caller never wonders whether anyone is listening. Get that right and the rest of your voice agent has a chance to shine.

Comments

Adsterra Have a blog? Monetize it with Adsterra (referral link)