fix(amd): make detection thresholds configurable and fix short-greeting voicemail misclassification#5490
Open
octo-patch wants to merge 1 commit intolivekit:mainfrom
Conversation
…il misclassification Fixes livekit#5477 Two related changes in the AMD classifier: 1. Expose HUMAN_SPEECH_THRESHOLD, HUMAN_SILENCE_THRESHOLD, and MACHINE_SILENCE_THRESHOLD as keyword arguments on both _AMDClassifier and the public AMD class. 2. Fix the short-greeting fast path: when speech ends within human_speech_threshold, the classifier previously emitted HUMAN unconditionally after a brief silence, ignoring transcript text that had already arrived via push_text(). When _classify_task is already running, the code now falls through to the LLM path so short voicemail greetings (e.g. paused mid-sentence at 2.3 s / 528 ms silence) are no longer misclassified as HUMAN.
|
octo-patch seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
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.
Fixes #5477
Problem
The AMD classifier's short-greeting fast path (
on_user_speech_ended) emitted aHUMANverdict unconditionally whenever speech duration was <=HUMAN_SPEECH_THRESHOLD(2.5 s) followed by >=HUMAN_SILENCE_THRESHOLD(0.5 s) of silence -- even when transcript text had already been delivered viapush_text()(meaning an LLM classification was already in flight).This caused voicemail greetings that paused mid-sentence (e.g. ~2.33 s speech / 528 ms silence) to be misclassified as
HUMANregardless of what the transcript said.Solution
Two changes:
1. Make detection thresholds configurable
HUMAN_SPEECH_THRESHOLD,HUMAN_SILENCE_THRESHOLD, andMACHINE_SILENCE_THRESHOLDare now keyword arguments on both_AMDClassifierand the publicAMDclass, so callers can tune detection behaviour without patching module-level constants.2. Fix the short-greeting fast path
When
_classify_taskis already running at the timeon_user_speech_endedis called (indicating that transcript text has arrived), the fast-path HUMAN verdict is skipped. Instead the code falls through to the LLM path usingmachine_silence_threshold, so the LLM can classify the greeting from the available transcript.Testing
The fix is consistent with the existing flow:
push_text()already creates_classify_task, so detecting_classify_task is not Nonereliably indicates that transcript evidence is available. No new runtime dependencies are introduced.