-
Notifications
You must be signed in to change notification settings - Fork 177
refactor: improve interruption detection word count logic #809
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Remove condition that skipped word count check for empty/undefined STT text - Apply minInterruptionWords filtering uniformly to all speech scenarios - Normalize undefined/null transcripts to empty string for consistent handling - Update onEndOfTurn to use same splitWords logic as onVADInferenceDone - Add comprehensive test suite with 23 test cases covering: * Empty and undefined transcript handling * Word count threshold logic * Punctuation and whitespace handling * Integration scenarios between both methods This ensures consistent interruption behavior regardless of transcript content, preventing unwanted interruptions from silence or very short utterances. All 23 tests pass successfully.
|
…nsive interruption detection tests
…nsive interruption detection tests - Refactored onVADInferenceDone() to normalize undefined/null text and apply word count check consistently - Refactored onEndOfTurn() to use splitWords() for consistent word splitting with onVADInferenceDone() - Added 23 comprehensive unit tests covering all scenarios: empty strings, undefined, short/long speech, thresholds - All tests passing (23/23) - Added SPDX headers to REFACTORING_SUMMARY.md for REUSE compliance
|
please review this @toubatbrian :) |
| this.cancelPreemptiveGeneration(); | ||
| this.logger.info('skipping user input, new_transcript is too short'); | ||
| return false; | ||
| const wordCount = splitWords(info.newTranscript, true).length; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice catch!
toubatbrian
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LG! Left some comments
Removed tests for interruption threshold logic.
Removed tests for undefined and null handling normalization.
Description
This PR resolves an inconsistency in the interruption detection logic for
minInterruptionWordswithin LiveKit agents. Previously, the word count check was skipped for empty or undefined STT transcripts, leading to unwanted interruptions triggered by silence or very short utterances.Now, interruption filtering based on
minInterruptionWordsis uniformly enforced across all speech scenarios, ensuring robust and predictable turn detection regardless of transcript content.Changes Made
minInterruptionWordsfiltering uniformly to all speech scenarios.onEndOfTurnandonVADInferenceDoneto use the samesplitWordslogic.All 23 tests pass successfully.
Pre-Review Checklist
Testing
restaurant_agent.tsandrealtime_agent.tsfunction properly after changes/fix #785