feat: add speaking practice with Web Speech API#19
Open
fasuizu-br wants to merge 2 commits intosilvioprog:mainfrom
Open
feat: add speaking practice with Web Speech API#19fasuizu-br wants to merge 2 commits intosilvioprog:mainfrom
fasuizu-br wants to merge 2 commits intosilvioprog:mainfrom
Conversation
6 tasks
added 2 commits
February 16, 2026 19:19
Allow users to download their study data as a JSON file and import it back, enabling backup and transfer between devices. Export serializes all studies with version metadata; import validates and replaces current data after user confirmation via dialog.
Add pronunciation training feature to the study flow. After viewing a transcript, users can click "Practice speaking" to record their speech via the browser's native Web Speech API. The spoken text is compared word-by-word using an LCS (Longest Common Subsequence) algorithm, producing a colored diff (green=correct, red=missing, orange=extra) with an accuracy score badge. - Zero cost: uses native browser API, no external services - Zero new runtime dependencies - Graceful degradation: hidden if browser lacks support - 121 tests (57 speechUtils + 21 hook + 17 component + 26 existing) - 100% coverage on speechUtils.ts
bed78f3 to
8dda8f5
Compare
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
Architecture
New files (7):
src/lib/speechUtils.ts— Pure text comparison (normalizeText, LCS algorithm, buildDiff, compareTexts)src/hooks/useSpeechRecognition.ts— React hook wrapping Web Speech API with full state machinesrc/components/Study/SpeakingPractice.tsx— UI component (idle → listening → processing → done/error)src/lib/speechUtils.test.ts— 57 tests (normalization, LCS, diff, edge cases, stress tests)src/hooks/useSpeechRecognition.test.ts— 21 tests (state transitions, errors, cleanup, memory leaks)src/components/Study/SpeakingPractice.test.tsx— 17 tests (UI states, colors, interactions)src/test-setup.ts— jest-dom matchers setupModified files (5):
src/components/Study/Transcript.tsx— Integration pointsrc/vite-env.d.ts— Web Speech API TypeScript declarationsvitest.config.ts— jsdom environment + coverage configpackage.json/package-lock.json— Dev dependencies (@testing-library/react, jest-dom, jsdom, user-event)Test plan