Skip to content

Comments

Fix edge case in StreamAtt with PunctuationHistory selection method returning empty history#18

Merged
mgaido91 merged 8 commits intomainfrom
fix_streamatt_punct
Feb 11, 2026
Merged

Fix edge case in StreamAtt with PunctuationHistory selection method returning empty history#18
mgaido91 merged 8 commits intomainfrom
fix_streamatt_punct

Conversation

@sarapapi
Copy link
Contributor

@sarapapi sarapapi commented Feb 10, 2026

Why is needed?

The PunctuationTextHistory method of StreamAtt currently returns an empty list (history) when processing a textual history ending with a strong punctuation mark. This causes an index out of range error in the audio history selection part because the textual history results in being empty. Solves #17.

What does the PR do?

Modifies the PunctuationTextHistory to return at least one sentence before the last punctuation mark, so that we avoid empty lists. An assert is also added to the audio history part to make sure we can detect this incorrect behavior.

How was the PR tested?

UTs

else:
self.text_history = new_output
new_history = self.text_history_method.select_text_history(self.text_history)
assert len(self.text_history) > 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure this is the right place. We might consider in the future cases where this is acceptable. I think we need to add the assert in _update_speech_history, where having 0 might cause issues. Also, please add as description of the assert an explanation of the thing with the hint of opening an issue in case someone hits the message. Something like:

assert len(self.text_history) > 0, \
    "Text history is empty after selection, so audio cannot be aligned. " \
    "If you encounter this message, it indicates a bug, so please open an issue at " \
    "https://github.com/hlt-mt/simulstream/issues and include the steps that led to this state."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to _update_speech_history, thanks!

@mgaido91
Copy link
Contributor

LGTM, thanks

@mgaido91 mgaido91 merged commit 82c75ee into main Feb 11, 2026
1 check passed
@sarapapi sarapapi deleted the fix_streamatt_punct branch February 19, 2026 10:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants