feat(tts): add includes_inter_frame_spaces flag to word-timestamp API#4330
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
... and 15 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Some TTS providers (e.g. Inworld) return verbatim tokens where spaces and punctuation are already embedded in the token text. When downstream consumers join these tokens with an extra space they produce "hello , world" instead of "hello, world". Add an opt-in `includes_inter_frame_spaces: bool = False` parameter to `add_word_timestamps` / `_add_word_timestamps`. The flag is threaded through `_WordTimestampEntry` and stamped onto every emitted `TTSTextFrame`. Defaults to `False` — no behaviour change for existing services. `InworldTTSService` passes `includes_inter_frame_spaces=True` and stops pre-processing tokens in `_calculate_word_times`, returning them verbatim. Tests added to `test_tts_frame_ordering.py` covering both HTTP and WebSocket delivery paths: verbatim text preservation, PTS ordering, text-before-audio ordering, and the Inworld punctuation-token scenario. Made-with: Cursor
58a0708 to
b435ddf
Compare
filipi87
approved these changes
Apr 22, 2026
Contributor
Author
|
Regarding making |
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.
Some TTS providers return verbatim tokens where spaces and punctuation are already embedded (e.g. Inworld). Joining these with an extra space produces
hello , worldinstead ofhello, world.Changes:
TTSService.add_word_timestamps/_add_word_timestamps/_WordTimestampEntrygain an opt-inincludes_inter_frame_spaces: bool = Falseflag, threaded through to every emittedTTSTextFrame. Defaults toFalse— no change for existing services.InworldTTSServicepassesincludes_inter_frame_spaces=Trueand returns tokens verbatim from_calculate_word_times.test_tts_frame_ordering.pycover HTTP and WebSocket paths: verbatim text, PTS ordering, text-before-audio ordering, and the Inworld punctuation-token scenario.