Add SpeechTextInput for dictation support in any text input - #1066
Merged
Conversation
This can happen if your token gets revoked, etc.
It handles all the dictation stuff now, which is necessary because we're supporting speech recognition in multiple text inputs across Robrix. The `MentionableTextInput` widget now uses it, which means it's visible and supported in the regular room input bar and the editing pane. Refactoring it into one widget makes it easier to fix key problems: * If you navigated away from a room, dictation kept recording and inserting text into a now-hidden text input, which is dumb. Now any kind of navigation away from the text input will cancel dictation. But not lost focus, so you can still dictate into one room while typing into a different room, side-by-side. * We modified `robius-speech` to enforce the "one session at a time" rule, which makes everything easier to deal with at the app-level. * Pressing escape to stop dictation only stops dictation, it's not treated as a regular escape press by other widgets like modals.
The `RoomFilterInputBar` widget now uses `SpeechTextInput`. We drop punctuation and other irrelevant characters that are often added by speech recognizers, e.g., "Robrix." will become "Robrix" so it matches any room containing "Robrix". Clearing the filter input bar's inputted text also stops dictation.
Pressing escape stops dictation but is also handled by other widgets like modals, so we don't want it to be doubly handled. UI-wise, fix up the microphone button's spacing and padding and ensure that it's vertically centered and nicely sized in the text input
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.
SpeechTextInputis a text input wrapper with a mic button that handles all thedictation logic, which is necessary now that we support speech recognition in
multiple text inputs across Robrix.
MentionableTextInputuses it, so dictation is visible and supported in theregular room input bar and the editing pane.
RoomFilterInputBaruses it too, for the rooms list and Space lobby filter bars.Punctuation that recognizers often add is dropped, e.g. "Robrix." becomes "Robrix"
so it still matches any room containing "Robrix". Clearing the filter text also
stops dictation.
a now-hidden input. Losing focus doesn't, so you can dictate into one room while
typing into another, side by side.
robius-speechenforces the "one session at a time" rule, which makes this mucheasier to deal with at the app level.
a regular escape press by modals and other widgets.
robius-speechto upstream now that its PR merged, including the dictationchar-boundary fix (speech: don't assume byte ranges are always at a char boundary robius#26).