fix(fallback): prewarm all instances in LLM/STT/TTS FallbackAdapters; fix soniox RECOGNITION_USAGE under-reporting - #6589
Open
priyam-garg wants to merge 1 commit into
Conversation
… fix soniox RECOGNITION_USAGE under-reporting - LLM FallbackAdapter: add prewarm() that delegates to all contained LLM instances. Previously missing entirely, leaving every fallback LLM cold. - STT FallbackAdapter: add prewarm() that delegates to all contained STT instances. Previously missing entirely. - TTS FallbackAdapter: fix prewarm() to iterate all TTS instances instead of only prewarm()'ing index [0]. When the primary fails, fallback providers must already have warm connections to avoid a latency spike. - livekit-plugins-soniox: fix RECOGNITION_USAGE under-reporting (livekit#6584). Previously _report_processed_audio_duration() was only called on endpoint tokens (<end>/<fin>) and on finished/error messages, silently skipping every interim-only message. Now called unconditionally after each message; the helper's internal delta tracking (_reported_duration_ms) prevents any double-counting.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two independent bugs found in the fallback adapters and Soniox plugin.
Bug 1 —
RECOGNITION_USAGEunder-reporting inlivekit-plugins-soniox(fixes #6584)Root cause:
_report_processed_audio_duration()was only called on endpointtokens (
<end>/<fin>) and onfinished/has_errormessages. Everyinterim-only message silently advanced
total_audio_proc_mswithout emittinga
RECOGNITION_USAGEevent, causing heavy under-reporting of STT usage.Fix: Call
_report_processed_audio_duration(total_audio_proc_ms)unconditionallyat the end of every message. The helper's
_reported_duration_msdelta trackingalready prevents double-counting.
Bug 2 —
FallbackAdapter.prewarm()does not warm fallback providersAll three fallback adapters had the same bug: when a primary provider fails,
the fallback's connection is cold (no DNS, no TLS), adding latency exactly
when it matters most.
tts.FallbackAdapter_tts_instances[0]stt.FallbackAdapterprewarm()at allllm.FallbackAdapterprewarm()at allFiles Changed
livekit-plugins/livekit-plugins-soniox/livekit/plugins/soniox/stt.pylivekit-agents/livekit/agents/tts/fallback_adapter.pylivekit-agents/livekit/agents/stt/fallback_adapter.pylivekit-agents/livekit/agents/llm/fallback_adapter.pyChecklist
ruff check— All checks passedruff format --check— All files already formatted