I am currently using claude haiku 4.5 model as an ...
# ask-ai
q
I am currently using claude haiku 4.5 model as an LLM for the voice AI agent. I am seeing a bit of latency at the introduction. What can I do to reduce that? Our introduction is static and we really do not need an LLM to say the introduction. I was thinking may be for the introduction we can not have an LLM call. Is it possible? Suggest me some ways, or other ideas using which I can reduce the latency.
t
Thanks for reaching out, Harsh. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — this is a great question. You’re right: if your introduction is static, calling an LLM for it adds unnecessary latency. Below are practical ways to reduce the intro delay plus a few extra optimizations you can try. Acknowledgement • You asked whether it’s possible to avoid an LLM call for a static introduction and for other ways to reduce latency. Yes — it’s possible and recommended. Primary recommendation (fastest, simplest) • Use direct TTS playback for the static intro instead of an LLM. Call the agent TTS directly (for example,
session.say(...)
) to synthesize and play the fixed introduction immediately. This bypasses LLM inference entirely and removes that delay. • Example behavior: ◦ Play the pre-recorded or TTS-generated intro immediately on session start. ◦ After the intro completes, route to your normal LLM-driven conversation flow. Implementation tip 1. Use
session.say()
(or your equivalent TTS call) for the fixed intro text. ◦ Set
allow_interruptions=False
if you want the intro to play to completion without being cut off. 1. After
session.say()
finishes, begin normal STT → LLM → TTS logic for dynamic responses. Other latency-reduction options to consider • Pre-generate and cache the intro audio: ◦ If you prefer a specific voice or higher-quality audio, synthesize the intro once and store the audio file. Play the stored audio instantly instead of calling TTS at runtime. • Preemptive generation for follow-ups: ◦ Enable preemptive generation for the LLM so it can start producing a response while the user is still speaking, reducing perceived reply time once VAD detects end-of-speech. • Co-locate services / reduce network hops: ◦ Run your agent close to (same region / data center) your STT/TTS/LLM providers to reduce network latency. • Provisioned inference capacity: ◦ Use provisioned inference resources where available (to avoid queuing and cold starts) for your dynamic LLM calls. • Monitor metrics: ◦ Track Time To First Token / Time To First Byte and STT/TTS timings to identify whether the bottleneck is network, LLM warmup, STT latency, or TTS rendering. Decision flow summary (simple) 1. Static intro → Use
session.say()
or play cached audio. 2. After intro → Start normal LLM-driven flow (consider
preemptive_generation
). 3. If dynamic introduction is needed later → consider short, cached prompts or small local rule-based responses to avoid full LLM calls. If you want, I can: • Show a small code snippet for your runtime language (Python / Node) to integrate
session.say()
and then start the LLM flow. • Help you decide between TTS-on-demand vs cached audio based on your voice/quality needs. Which would you prefer: a code snippet for Python or Node, or help picking between cached audio vs on-the-fly TTS? Sources: Agent speech and audio | LiveKit Documentation | examples/drive-thru | livekit/livekit_composite | DeepWiki | Introducing LiveKit Inference: A unified model interface for voice AI | LLM Metrics | LiveKit Documentation | How can I reduce latency in voice agents using STT, TTS and LLM? | LiveKit
q
But the issue is, sometimes we face an IVR or some other pre recorded message in the beggining. If we just do session.say(), it will give introduction to the IVR, which we do not want. What are some ways where we can handle IVR and pre-recorded messages and only say introduction if an actual human starts the conversation
t
Great question — that’s a common real-world problem. You want the intro to play only when a human answers (not during IVR or pre-recorded messages). Below are practical strategies you can use, plus trade-offs and a suggested combined approach. Acknowledgement • You want to avoid playing the intro into IVR/pre-recorded messages and only play it when a real human is on the line. Below are options to detect that and handle it reliably. Options to detect IVR / pre-recorded prompts 1) Voice activity + speech characteristics (VAD + human-speech heuristics) • What it does: Use VAD to detect when audio contains speech, then analyze characteristics like continuous speech patterns, pauses, pitch variation, and speech rate. • Why it helps: IVR and pre-recorded prompts often have long, perfectly paced speech without the micro-pauses, breathing, or variable pitch found in human speech. • When to use: Good first step and low cost. • Trade-offs: Heuristic-based and may have false positives/negatives in noisy calls. 2) Detect DTMF / IVR tones • What it does: Listen for DTMF tones or menu prompts (short tones, beeps, or explicit IVR phrases). • Why it helps: Presence of DTMF or known IVR prompts is a strong signal you’re in an IVR flow. • When to use: Useful when interacting with systems that use touch-tone menus. • Trade-offs: Not all IVRs produce DTMF; some are voice-driven. 3) Silence/response timing analysis • What it does: Measure timing between playback and responses. IVR systems often respond immediately and deterministically; humans take longer and include hesitations. • Why it helps: Fast, predictable responses right after prompts often indicate an automated system. • Trade-offs: Timing thresholds need tuning and may vary by locale/network conditions. 4) Speaker / channel fingerprinting or voiceprint models • What it does: Use a classifier trained to detect machine vs human speech (models that detect “synthetic” vs “natural” or “broadcast” speech). • Why it helps: More accurate in distinguishing pre-recorded/IVR audio from live human speech. • When to use: When accuracy requirement is high and you can run or call a small classifier. • Trade-offs: Requires model development or a third-party classifier and more compute. 5) Use call metadata and SIP signaling • What it does: Inspect SIP headers, Caller ID behavior, or telephony provider metadata (e.g., how the call was bridged) to infer if the call was answered by a human or an automated system. • Why it helps: Sometimes carriers or PBX systems tag automated answers. • Trade-offs: Metadata availability depends on your telephony provider and setup. 6) Play a short probe (non-invasive) and listen for natural responses • What it does: Play a very short, non-intrusive audio probe (e.g., a soft beep or “Hello?”) and listen for natural human responses (utterances, hesitations). • Why it helps: Direct test — if a human responds naturally, proceed with full intro; if IVR or silence, don’t. • Trade-offs: Adds a small latency and must be designed to avoid confusing IVR systems or violating regulations. Suggested combined approach (practical and robust) 1. Start listening on call answer — do not auto-play intro. 2. Run lightweight checks in parallel: ◦ Apply VAD and short human-speech heuristics immediately. ◦ Monitor for DTMF tones or known IVR cues. ◦ Check call metadata if available. 1. If heuristics are inconclusive after a short timeout (e.g., 1–2s), play a very short probe like “Hello?” or a soft audio tag. ◦ If we detect a natural human reply (VAD + speech with human characteristics), then play your full intro via
session.say()
or cached audio. ◦ If probe elicits IVR-like responses or DTMF or no human response within a short window, skip the intro. 1. If you expect many false positives/negatives, add a classifier step (server-side) to examine a few seconds of audio and return a machine/human score before intro playback. Implementation notes and tips • Use cached audio for the intro (pre-synthesized file) so playback is instantaneous once you decide to play. • Keep probe audio short and neutral to avoid interacting with IVR menus. • Tune detection timeouts to balance speed and accuracy. A 1–2 second decision window often works well. • Log decisions and false-positive cases so you can iteratively improve heuristics and thresholds. • Consider legal/regulatory constraints for playing automated messages — ensure probes follow local laws. If you’d like, I can: • Provide a compact code example (Python or Node) showing a flow that: 1) Listens for a few seconds, 2) Runs VAD/DTMF checks, 3) Plays a probe, 4) Decides whether to play the cached intro. • Help pick thresholds or a small ML classifier approach if you want higher accuracy. Which would help more: a code snippet in Python or Node, or a sample decision flow with recommended thresholds?