Skip to content

feat: Add interimResults prop for live (interim) transcripts#272

Open
untemps wants to merge 1 commit into
betafrom
feat/interim-results
Open

feat: Add interimResults prop for live (interim) transcripts#272
untemps wants to merge 1 commit into
betafrom
feat/interim-results

Conversation

@untemps

@untemps untemps commented Jul 1, 2026

Copy link
Copy Markdown
Owner

What

Thread the Web Speech API's interimResults flag through useVocal and the <Vocal> component so consumers can render live captions as the user is still speaking.

  • New <Vocal interimResults> prop (default false) and 5th argument useVocal(lang, grammars, maxAlternatives, continuous, interimResults), forwarded to createVocal (already supported by @untemps/vocal@2.2.0).
  • In non-continuous mode, _onResult now finalizes (matches commands and stops the session) only on the final segment, gated on SpeechRecognitionResult.isFinal. An interim result no longer truncates the session.
  • Backward-compatible: absent isFinal (interimResults off, or synthetic aggregated events) still counts as final, so existing behavior is unchanged.

Why

Live/interim transcripts are the most compelling thing to show for speech recognition, and the demo revamp (stacked PR) uses this for its dictation card. Without it, interimResults couldn't reach createVocal.

Tests

  • New coverage in useVocal.test.ts (factory forwarding, teardown/recreate on change) and Vocal.test.tsx (interim streams to onResult without ending; final ends + matches).
  • 212 tests pass, branches coverage 93.8% (threshold 85%), typecheck + build + bundle verification green.
  • README updated (both the <Vocal> props table and the useVocal signature).

🤖 Generated with Claude Code

Thread the Web Speech API's interimResults flag through useVocal and the
<Vocal> component so consumers can render live captions as the user is
still speaking.

In non-continuous mode, an interim result no longer discards the session:
_onResult finalizes (matches commands and stops) only on the final segment,
gated on SpeechRecognitionResult.isFinal. Absent isFinal (interimResults
off, or synthetic aggregated events) still counts as final, so existing
behavior is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants