Repository navigation
feat(audio): add opt-in browser dictation - #3039
berdebotond wants to merge 1 commit into
Conversation
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
1 issue found across 9 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="frontend/src/components/chat/MessageComposer/index.tsx">
<violation number="1" location="frontend/src/components/chat/MessageComposer/index.tsx:101">
P3: The onTranscript handler appends dictated text to the React `value` state: `setValueExtern([value, text].join(' '))`. If two final recognition results arrive before React re-renders, both use the same stale `value`, so the second overwrites the first instead of appending to it and dictated text is lost. Read the live input text rather than the `value` state (e.g., from `inputRef.current` or an accumulating ref) so consecutive results always build on the latest content.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| const dictation = useBrowserSpeechRecognition({ | ||
| enabled: browserDictation && !disabled, | ||
| language: i18n.language, | ||
| onTranscript: (text) => { |
There was a problem hiding this comment.
P3: The onTranscript handler appends dictated text to the React value state: setValueExtern([value, text].join(' ')). If two final recognition results arrive before React re-renders, both use the same stale value, so the second overwrites the first instead of appending to it and dictated text is lost. Read the live input text rather than the value state (e.g., from inputRef.current or an accumulating ref) so consecutive results always build on the latest content.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At frontend/src/components/chat/MessageComposer/index.tsx, line 101:
<comment>The onTranscript handler appends dictated text to the React `value` state: `setValueExtern([value, text].join(' '))`. If two final recognition results arrive before React re-renders, both use the same stale `value`, so the second overwrites the first instead of appending to it and dictated text is lost. Read the live input text rather than the `value` state (e.g., from `inputRef.current` or an accumulating ref) so consecutive results always build on the latest content.</comment>
<file context>
@@ -89,6 +92,17 @@ export default function MessageComposer({
+ const dictation = useBrowserSpeechRecognition({
+ enabled: browserDictation && !disabled,
+ language: i18n.language,
+ onTranscript: (text) => {
+ inputRef.current?.setValueExtern([value, text].filter(Boolean).join(' '));
+ },
</file context>
|
This PR is stale because it has been open for 14 days with no activity. |
|
Could you tell us the status of this PR, please? |
Adds opt-in browser speech-to-text for #3003. With
[features.audio] enabled = trueandmode = "browser", the microphone usesSpeechRecognition/webkitSpeechRecognitionand appends finalized transcripts to the composer. Users can edit the text and submit through the normal message path, retaining selected commands and attachments.The existing Python audio streaming path remains the default (
mode = "realtime"). Browser mode requires no Python audio callbacks. Recognition stops on submit, disables/unmounts safely, handles microphone/start errors, avoids duplicate final results, and shows a disabled microphone when unsupported. The README and generated config explain browser support and possible vendor-hosted recognition.Validation:
Fixes #3003
AI assistance: implemented and tested with Codex at the contributor's request, credited in the commit as required by AGENTS.md.
Summary by cubic
Fixes #3003 by adding opt-in browser dictation. With
features.audio.mode = "browser", the composer microphone uses the Web Speech API and appends finalized transcripts for editing and normal submission;mode = "realtime"with Python audio callbacks remains the default.SpeechRecognitionorwebkitSpeechRecognition.Written for commit 86cec9a. Summary will update on new commits.