I am using a different ONNX turn model detector fo...
# ask-ai
b
I am using a different ONNX turn model detector for live kit. Is it good to use ?
✅ 1
t
Thanks for reaching out, Waleed. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
Thanks — I’m responding to your question about using a different ONNX turn model detector with LiveKit. Short answer: you can try a custom ONNX model, but LiveKit’s MultilingualModel is recommended for best performance and integration. What to consider if you use a different ONNX model: • Ensure the model accepts the same inputs (STT transcripts / conversational context) and produces a turn-completion confidence compatible with LiveKit’s turn detector flow. • Latency: aim for real-time inference (target <50ms) and keep CPU/memory usage low (LiveKit’s detector runs on CPU with <500 MB RAM). • Accuracy & language support: test that your model reduces false positives/negatives compared to VAD-only; LiveKit’s model significantly reduces interruptions. • Use Silero VAD alongside any STT/model-based detector for responsive interruption handling. • Validate end-to-end behavior (interruption handling, edge cases) in realistic calls before rolling out. Could you share: • the ONNX model name/source, • expected inputs/outputs (tensor shapes / labels), • and your latency / deployment constraints? With that I can give specific integration advice and testing steps. Sources: LiveKit turn detector plugin | LiveKit Documentation | Using a transformer to improve end of turn detection | LiveKit | Turns overview | LiveKit Documentation | Deepgram STT | LiveKit Documentation | Open-source wake word training in a single command | LiveKit, with interactive elements
b
These are the config that I am using currently
Copy code
Agent level (CampaignAgent / SimpleAgent):
  min_endpointing_delay: 0.4s
  max_endpointing_delay: 0.8s

Session level (AgentSession):
  turn_handling:
    turn_detection: InProcessTurnDetector (ONNX model, in-process)
    endpointing:
      min_delay: 0.4
      max_delay: 0.8
  
  vad: Silero VAD (preloaded in prewarm)
  aec_warmup_duration: 0.0 (disabled)
  
STT level (Deepgram):
  endpointing_ms: 100
  interim_results: True
  no_delay: True
  sample_rate: 8000
All Available Options (LiveKit Agent SDK) TurnHandlingOptions
Copy code
turn_handling = {
    "turn_detection": "stt" | "vad" | "realtime_llm" | "manual" | InProcessTurnDetector,
    
    "endpointing": {
        "mode": "fixed" | "dynamic",  # We use dynamic (via turn detector)
        "min_delay": 0.4,             # Min wait after silence (seconds)
        "max_delay": 0.8,             # Max wait before forcing end of turn
    },
    
    "interruption": {
        "enabled": True,                      # Allow user to interrupt agent
        "mode": "adaptive" | "vad",           # How to detect interruptions
        "discard_audio_if_uninterruptible": False,
        "min_duration": 0.3,                  # Min speech to count as interruption
        "min_words": 1,                       # Min words to count as interruption
        "resume_false_interruption": True,     # Resume if user didn't actually interrupt
        "false_interruption_timeout": 0.5,     # Seconds to wait before deciding it's false
    },
    
    "preemptive_generation": {
        "enabled": True,              # Start LLM before user finishes (speculative)
        "preemptive_tts": True,       # Also start TTS speculatively
        "max_speech_duration": 10.0,  # Max seconds of preemptive speech
        "max_retries": 3,
    },
}
Other Session Options
Copy code
AgentSession(
    aec_warmup_duration=0.0,  # We disabled (was 3.0s default)
    ivr_detection=False,       # Auto-detect IVR phone menus
    user_away_timeout=15.0,    # Mark user "away" after silence
)
t
Thanks — I’m responding to your configuration and whether your in-process ONNX turn detector is a good fit. Overall: your config is reasonable, but there are a few checks and tweaks I recommend to ensure stability, low latency, and reliable interruption handling. Key checks and recommendations • Inputs/outputs: confirm your ONNX model consumes the STT transcript + context and returns a turn-completion confidence (or equivalent). If it expects raw audio instead, note the LiveKit turn detector expects semantic input from STT. • Latency & resources: verify inference latency is consistently low (aim <50 ms per decision) and memory <500 MB. The detector runs on CPU in-process; spikes will harm real-time behavior. • Alignment with endpointing: you’re using dynamic endpointing with min_delay 0.4 / max_delay 0.8 — ensure your model’s decision timing naturally fits inside that window (i.e., it can decide before max_delay). • VAD pairing: keep Silero VAD enabled (you have this) — VAD + model together improves responsiveness and interruption detection. • STT settings: your Deepgram endpointing_ms=100, interim_results=True, no_delay=True, sample_rate=8000 is aggressive and good for low latency. Ensure transcript quality at 8kHz is sufficient for semantic turn detection. • Interruption handling: enable
interruption.enabled=True
and use
mode: "adaptive"
if you want the model + VAD to drive interruptions. Tune
min_duration
and
min_words
to avoid false positives from short noises/interims. • Preemptive generation: if
preemptive_generation.enabled=True
, confirm your turn detector’s false-positive rate is very low — preemptive work can waste compute or cause awkward agent responses if the model mispredicts end-of-turn. • AEC warmup: you disabled aec_warmup_duration — ensure echo cancellation performance is fine without warmup for your telephony endpoints. Tests to run 1. Latency test: measure median and 95th-percentile decision latency under typical CPU load. 2. False positive/negative audit: run a 100–500 call sample and log model decisions vs ground-truth end-of-turn to compute false-interruption and missed-end rates. 3. Interruption simulation: simulate user interruptions mid-agent-speech to validate
resume_false_interruption
and
false_interruption_timeout
behavior. 4. End-to-end: validate with real callers (different accents/noise) because the multilinguistic LiveKit model was tuned for that. If you want help I can: • Review the model’s expected input/output spec if you paste it here. • Suggest concrete tuning values for
min_duration
,
min_words
, and
false_interruption_timeout
based on your false-positive/negative rates. • Suggest a simple test script to measure per-decision latency and resource usage. Which would you like me to do next? Also please share the ONNX model name/source and its input/output shapes or an example inference payload. , with interactive elements
b
We we achieve retell like voice flow with live kit and what changes we will need to do in our config json ?
t
Thanks — I’m responding to your question about achieving a “retell-like” voice flow and what changes your config should include. Quick clarification: what do you mean by “retell-like”? Do you want the agent to: • Echo the user’s last utterance verbatim (repeat), • Summarize/paraphrase what the user said, • Recast the user’s input into a scripted flow (e.g., confirm + rephrase), or • Something else (describe the behavior)? Once you confirm, I’ll suggest the exact AgentSession/turn_handling/VAD/STT/LLM/TTS settings (and concrete values) to implement it and any test cases to validate behavior. Sources: Open-source wake word training in a single command | LiveKit | LiveKit | Contact sales | LiveKit | Agents Framework | livekit/livekit_composite | DeepWiki | Sequential Pipeline Architecture for Voice Agents | LiveKit, with interactive elements
b
Copy code
"interruption": {
    "enabled": True,
    "mode": "adaptive",
    "min_duration": 0.3,
    "min_words": 1,
    "resume_false_interruption": True,
    "false_interruption_timeout": 0.5,
},
"preemptive_generation": {
    "enabled": True,
    "preemptive_tts": True,
}
What will be teh effect of these are these good to go settings ?
t
Thanks — I’m responding to your interruption and preemptive_generation settings and whether they’re good to go. Short answer: these settings are reasonable for a responsive, interruptible agent, but they carry trade-offs you should validate with tests. What these settings do • interruption.enabled = True ◦ Allows users to cut in while the agent speaks. • mode = "adaptive" ◦ Uses VAD + turn-detection signals (your ONNX detector + Silero VAD) to determine interruptions rather than VAD-only heuristics. • min_duration = 0.3 / min_words = 1 ◦ A short segment (≥0.3s and ≥1 word) will count as a valid interruption. This makes interruption detection sensitive and responsive. • resume_false_interruption = True / false_interruption_timeout = 0.5 ◦ If the system detects an interruption but within 0.5s decides it was a false alarm, the agent will resume its prior speech. This prevents brief noises from permanently cancelling the agent response. • preemptive_generation.enabled = True / preemptive_tts = True ◦ The agent will start LLM inference (and TTS) speculatively before the user fully finishes, reducing perceived latency when a turn ends. Risks and trade-offs • False positives: short thresholds (0.3s / 1 word) increase the chance of treating brief noises or partial words as interruptions. That can cause unnecessary cutoffs or wasted preemptive work. • Wasted compute / awkward speech: with preemptive_tts enabled, mispredicted end-of-turns can produce partial TTS that must be discarded or lead to stuttering for callers. • Latency sensitivity: preemptive behavior requires very low turn-detection false-positive rates and low inference latency to be beneficial. Practical recommendations • Run targeted tests: a. Interruption robustness: simulate quick user cut-ins and background noises to measure false-interruption rate. b. Resume behavior: verify agent resumes smoothly when false interrupts occur. c. Preemptive ROI: measure perceived latency reduction vs percentage of wasted preemptive TTS. • If false positives are frequent, raise thresholds: try min_duration = 0.5 and/or min_words = 2, and increase false_interruption_timeout to 0.7–1.0s. • If preemptive TTS causes awkward partial speech, set preemptive_tts = False (keep preemptive_generation.enabled to warm LLM only), or reduce preemptive max duration in
preemptive_generation
(e.g., cap speculative TTS shorter). • Keep Silero VAD + your turn detector tuned and verify STT interim quality at 8kHz to reduce mis-detections. If you want, I can: • Suggest specific tuned values based on your measured false-positive rate, or • Provide a short test plan and logging metrics to evaluate interruption vs preemptive effectiveness. Which would you like next? , with interactive elements