feat(web): live-preview transcription while recording - #124
Merged
Conversation
The voice composer only ever showed a transcript after a recording finished. Start MediaRecorder with a 3 second timeslice so it now fires periodic dataavailable events during recording, and re-transcribe the growing clip on each one to keep an interim result visible while the person is still talking. Each live tick is tracked as a span in the textarea (start, end, and the text it holds), so the next tick can replace it in place instead of appending. If the person edits that span themselves, live preview is abandoned for the rest of the recording rather than clobbering their edit, and the final stop-triggered transcribe falls back to inserting at the cursor exactly as it does today. A live request in flight suppresses the next tick rather than queuing it, and a failing tick is silent since only the final transcribe is meant to surface errors. insertTranscript now returns the span it just inserted so both the first live insert and the final commit can share the same span-tracking logic. Cancelling a recording splices out an still-untouched live span the same way. Refactored voice-input.test.ts's FakeRecorder to attach data to the dataavailable stop() fires on its own (finalData), so tests that only need a non-empty recording no longer have to dispatch a mid-recording dataavailable, which now also means a live-preview tick. Added tests for periodic replacement, abandonment on edit, span removal on cancel, silent tick failures, in-flight suppression, and unchanged final-transcribe behavior. Claude-Session: https://claude.ai/code/session_01KGPVQ8wUG7h36zashWYCp4
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.
Summary
MediaRecorder.start()now uses a 3 second timeslice, and each periodicdataavailablere-transcribes the growing clip through the existingVoiceApi.transcribe()call.{start, end, text}span), rather than appending on every tick. If the user edits that span, live preview is abandoned for the rest of the recording and the final transcribe falls back to inserting at the cursor exactly as it did before this change. Cancel splices out a still-untouched live span the same way.console.error, no status change), a request already in flight suppresses the next tick instead of queuing it, and the final, stop-triggered transcribe keeps its existing messages and error handling unchanged.web/src/voice-input.tsandweb/test/voice-input.test.ts. No Rust changes, no other frontend files.zorp-voice's transcription endpoint is already stateless per-request and needed no changes to support repeated calls.Test plan
npm run check(fromweb/) — passes cleannpm test(fromweb/) — all 282 tests pass, including 6 new live-preview tests and 3 existing tests adjusted to seed recorded audio via a newFakeRecorder.finalDatafixture field instead of a mid-recordingdataavailabledispatch (which now also triggers a live tick)npm run build(fromweb/) — passes cleanClaude-Session: https://claude.ai/code/session_01KGPVQ8wUG7h36zashWYCp4