Repository navigation
feat(voice): release a reply's opening chunk at a clause or word boundary, and drop indented code from speech (#13103, #17953) #17972
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
Draft
mrveiss
wants to merge
38
commits into
main
Choose a base branch
from
issue-13103-tts-fast-start
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
2007be4
feat(voice): release a reply's opening chunk at a clause or word boun…
mrveiss 81d9ddf
Merge branch 'main' into issue-13103-tts-fast-start
mrveiss 0967e7e
Merge branch 'main' into issue-13103-tts-fast-start
mrveiss b8220e1
Merge branch 'main' into issue-13103-tts-fast-start
mrveiss bb6ed4e
Merge branch 'main' into issue-13103-tts-fast-start
mrveiss 54dbfa7
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 50ac362
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 9e3c644
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 5b03e99
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 2c28bf3
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 7d93021
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] eb361db
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 9c262c4
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] d62f26d
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 876d769
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 70e37b1
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] fad1f2f
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 2ab6e2a
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 30f27ef
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] d57ab76
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] db30776
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] d45158f
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 32a0f96
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 7f88d5f
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 44d5907
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 8485661
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 12ee43f
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 300e593
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 7ae620f
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 9dd13b6
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] f010e6d
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 2915de8
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 0611934
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 2b61afe
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] d46a9d6
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] f4f6e70
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 231a607
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] 7352b94
Merge branch 'main' into issue-13103-tts-fast-start
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
104 changes: 104 additions & 0 deletions
104
autobot-frontend/src/utils/__tests__/ttsFastStart.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| // Copyright 2025-2026 mrveiss | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| /** | ||
| * Opening-chunk fast start (#13103): the first chunk of a reply goes to TTS at | ||
| * a clause or word boundary, everything after it keeps the terminated-sentence | ||
| * rule, and the cursor advances by exactly the consumed span. | ||
| */ | ||
| import { describe, it, expect } from 'vitest' | ||
| import { | ||
| createTtsStream, | ||
| extractOpeningChunk, | ||
| MIN_TTS_SENTENCE_CHARS, | ||
| OPENING_CLAUSE_MIN_CHARS, | ||
| OPENING_WORD_MIN_CHARS, | ||
| } from '../ttsSentences' | ||
|
|
||
| /** Feed `full` in `step`-char deltas the way ChatInterface's watcher does. */ | ||
| function stream(full: string, step: number, opened = false) { | ||
| const tts = createTtsStream(opened) | ||
| const spoken: string[] = [] | ||
| let cursor = 0 | ||
| for (let end = step; end < full.length + step; end += step) { | ||
| const { spans, consumed } = tts.next(full.slice(0, Math.min(end, full.length)).slice(cursor)) | ||
| spoken.push(...spans) | ||
| cursor += consumed | ||
| } | ||
| return { spoken, remainder: full.slice(cursor) } | ||
| } | ||
|
|
||
| describe('extractOpeningChunk (#13103)', () => { | ||
| it('releases the opening at a clause boundary below the standard bar', () => { | ||
| const text = 'Looking at your logs, the failure starts' | ||
| expect(text.indexOf(',') + 1).toBeGreaterThanOrEqual(OPENING_CLAUSE_MIN_CHARS) | ||
| expect(extractOpeningChunk(text)).toEqual({ spans: ['Looking at your logs, '], consumed: 22 }) | ||
| }) | ||
|
|
||
| it('skips a clause boundary that comes too early', () => { | ||
| expect(extractOpeningChunk('Well, that is')).toBeNull() | ||
| }) | ||
|
|
||
| it('falls back to a word boundary for a long opening with no early pause', () => { | ||
| const text = 'This opening sentence runs on for quite a while without any pause in it' | ||
| expect(text.length).toBeGreaterThanOrEqual(OPENING_WORD_MIN_CHARS) | ||
| const chunk = extractOpeningChunk(text)! | ||
| expect(chunk.spans[0]).toBe('This opening sentence runs on for quite a while without any pause in ') | ||
| expect(chunk.consumed).toBe(chunk.spans[0].length) | ||
| }) | ||
|
|
||
| it('never cuts the opening inside a markdown link', () => { | ||
| // The comma and every word gap sit inside the still-open link text. | ||
| expect(extractOpeningChunk('[see the docs for the parser, especially the long section on')).toBeNull() | ||
| // Once the link has closed, a later gap is a fair cut. | ||
| expect(extractOpeningChunk('[the docs](http://x.y/z) explain the parser in a long section on')!.spans[0]).toBe( | ||
| '[the docs](http://x.y/z) explain the parser in a long section ', | ||
| ) | ||
| }) | ||
|
|
||
| it('waits while the opening is short and has no clause boundary', () => { | ||
| expect(extractOpeningChunk('Short opening with no pause')).toBeNull() | ||
| }) | ||
|
|
||
| it('stays out of the way once any sentence has terminated', () => { | ||
| // "Hi there." is shorter than the standard bar, so it is HELD for merging; | ||
| // an early opening must not jump ahead of it. | ||
| expect('Hi there.'.length).toBeLessThan(MIN_TTS_SENTENCE_CHARS) | ||
| expect(extractOpeningChunk('Hi there. And then, after a long while it goes on')).toBeNull() | ||
| }) | ||
| }) | ||
|
|
||
| describe('createTtsStream (#13103)', () => { | ||
| it('speaks the opening early, then only terminated sentences', () => { | ||
| const tts = createTtsStream() | ||
| expect(tts.next('Looking at your logs, the failure')).toEqual({ spans: ['Looking at your logs, '], consumed: 22 }) | ||
| // After the opening, a clause boundary alone releases nothing. | ||
| expect(tts.next('the failure starts in the parser, then')).toEqual({ spans: [], consumed: 0 }) | ||
| expect(tts.next('the failure starts in the parser. Then')).toEqual({ | ||
| spans: ['the failure starts in the parser. '], | ||
| consumed: 34, | ||
| }) | ||
| }) | ||
|
|
||
| it('gives no fast start to a reply already under way', () => { | ||
| const tts = createTtsStream(true) | ||
| expect(tts.next('Looking at your logs, the failure')).toEqual({ spans: [], consumed: 0 }) | ||
| }) | ||
|
|
||
| it('treats a standard sentence as the opening when one arrives first', () => { | ||
| const tts = createTtsStream() | ||
| expect(tts.next('The build failed in the parser. Next')).toEqual({ | ||
| spans: ['The build failed in the parser. '], | ||
| consumed: 32, | ||
| }) | ||
| expect(tts.next('Next, we look at the tokenizer')).toEqual({ spans: [], consumed: 0 }) | ||
| }) | ||
|
|
||
| it.each([1, 3, 7, 50])('advances the cursor by the exact consumed span — no drift (step %i)', (step) => { | ||
| const full = | ||
| 'Looking at your logs, the failure starts in the parser. It reads a stray token.\n\nThe fix is small: skip it.' | ||
| const { spoken, remainder } = stream(full, step) | ||
|
|
||
| expect(spoken.join('') + remainder).toBe(full) | ||
| expect(spoken.length).toBeGreaterThan(0) | ||
| }) | ||
| }) |
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
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
Oops, something went wrong.
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.
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.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: mrveiss/AutoBot-AI
Length of output: 6349
🏁 Script executed:
Repository: mrveiss/AutoBot-AI
Length of output: 27917
🌐 Web query:
CommonMark specification indented code block inside list item blank line 8 spaces💡 Result:
Filter indented code blocks inside list items.
After
- item\n\n,inListremains true. The eight-spacesecret()line therefore bypasses the!inListcheck and reaches speech output. CommonMark treats this as an indented code block inside the list item, not list prose. Track the list item's content indentation so the existing four-space nested-list case remains spoken.Suggested fix