fix(voice_agent): recognize a sentence ending in a decimal number as complete - #16219
Open
udsy19 wants to merge 1 commit into
Open
fix(voice_agent): recognize a sentence ending in a decimal number as complete#16219udsy19 wants to merge 1 commit into
udsy19 wants to merge 1 commit into
Conversation
…complete
find_last_period_index()'s decimal/bullet/abbreviation heuristics only run
when the buffered text contains exactly one period. As soon as a second
period appears anywhere in the buffer -- including the decimal point of the
sentence's own trailing number -- those checks are skipped, and the code
falls through to a blanket "digit before the period means partial decimal"
rule. Any sentence ending immediately after a decimal number (e.g. "It costs
$3.14.", the has_partial_decimal docstring's own example of a sentence that
is "clearly ... complete") is therefore misclassified as incomplete, and the
real-time voice agent never flushes it to TTS at its natural sentence
boundary.
Narrow the fix to the specific ambiguity: a digit before the period is only
treated as an in-progress decimal when the substring up to that period does
not already look like a closed-off decimal number ("X.Y."). Verified against
a battery of existing correctly-handled cases (bullets, abbreviations, a.m./
p.m., bare trailing numbers like "at 3.") with zero behavior changes.
Signed-off-by: Udaya Tejas <udayatejas2004@gmail.com>
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.
What does this PR do ?
Fixes the voice agent's text aggregator so a sentence ending in a decimal
number (e.g. "It costs $3.14.") is recognized as complete instead of being
buffered forever.
Collection: [voice_agent]
Changelog
simple_text_aggregator.py:find_last_period_index's decimal/bullet/abbreviation heuristics only ran when the buffered text had exactly one
period. A second period -- including the decimal point of the sentence's
own trailing number -- skipped those checks and fell through to a blanket
"digit before the period -> partial decimal" rule, contradicting
has_partial_decimal's own docstring example ("It costs $3.14."is"clearly ... complete"). Narrowed the fix: a digit before the period is
only treated as an in-progress decimal when the text up to that period
isn't already a closed-off decimal number (
"X.Y."). Verified against thefile's other heuristics (bullets, abbreviations, a.m./p.m., bare trailing
numbers like
"at 3.") with zero behavior changes.tests/agents/voice_agent/test_simple_text_aggregator_decimal_boundary.py.nemo.agents.voice_agentneeds the optionalpipecat-ai/logurustack,not part of this repo's test env, so the test stubs both in
sys.modulesto import the real module and call
find_last_period_indexdirectly.Usage
Negative control (
simple_text_aggregator.pyreverted tomain, new testsunchanged):
4 failed, 3 passed in 0.07s-- the 3 passes are the existing,still-correct ambiguous/bullet/abbreviation cases, proving the fix targets
only the misclassified ones. With the fix:
7 passed in 0.03s.GitHub Actions CI
Requires a maintainer
/ok to test <head-sha>.Before your PR is "Ready for review"
Pre checks:
PR Type:
Additional Information
Signed-off-by: Udaya Tejas udayatejas2004@gmail.com