Repository navigation
feat: on-device captions (whisper.rn) with GPU accel + model picker - #14
Merged
Merged
Conversation
Add an app-wide, background speech-to-text engine that keeps every clip in the library captioned on-device, with a model picker and read-only caption rendering in the recorder preview. Engine (src/features/transcription/) - Single global engine mounted once at the root (TranscriptionProvider). Driven by the persisted model selection, it downloads the chosen model (keeping only one set of weights on disk), transcribes the whole library, picks up new/edited clips automatically, and yields to the camera while recording. - Persistence: new `transcripts` (one row per segment, keyed by the effective file so a destructive edit re-runs) and `settings` (KV) tables; resume of work stranded by a killed app. - Whisper runs with GPU/Metal + Flash Attention (CPU fallback), decodes in the model's language (en for the .en models, auto for multilingual), and emits caption-sized lines (maxLen + token timestamps). - The on-screen draft is captioned first (active-draft signal). - Bounded per-clip error retry; in-flight downloads cancel on switch; large downloads prompt for confirmation. Tooling - Pin whisper.rn to 0.6.0 (matches repo convention). - Add a jest runner (no new deps: babel-jest + @jest/globals) with unit tests for the timeline math, the transcription decision/retry logic, and the model catalog.
- Swap the home-header icon from captions.bubble to sparkles (accent tint when a model is active), so it reads as on-device AI rather than captions-specific. - Reframe the modal as "On-device AI": a privacy-forward header and a "Captions" section, structured so future on-device features slot in as additional sections. Generalize the remove action copy.
Move the __DEV__ home-header seed buttons (+ seed / s2 / s3 / clear) into their own component, loaded via a __DEV__-guarded require. Metro's dead-code elimination then drops both the component and @/dev/seed (with its perf-test fixtures) from the release bundle — previously the static import bundled the seed module in production even though the buttons only rendered in dev. Verified against a production iOS export: the dev string literals are absent from the Hermes bytecode, while prod UI strings remain.
The sparkle button shared the headerRight flex container with the dev seed row and was bottom-aligned, so it read as part of the dev cluster. Make it a standalone top-right header action centered with the title, and move the dev-only seed row onto its own line below the header.
Pair the sparkles icon with an "AI" text label (both accent-tinted when a model is active) so the entry point is self-explanatory.
morepriyam
added a commit
that referenced
this pull request
Aug 12, 2026
feat: on-device captions (whisper.rn) with GPU accel + model picker
morepriyam
added a commit
that referenced
this pull request
Aug 12, 2026
…advisories Bumps transitive dependency resolutions already permitted by existing semver ranges declared by Expo's own packages and devDependencies: - js-yaml 3.15.0 -> 3.15.1 (babel-plugin-istanbul, dev-only) - js-yaml 4.3.0 -> 4.3.1 (@expo/xcpretty, eslint's @eslint/eslintrc) - brace-expansion 5.0.7 -> 5.0.9 (minimatch used by @expo/cli, @expo/config, @expo/config-plugins, @expo/fingerprint, @expo/metro-config) - brace-expansion 1.1.16 -> 1.1.18 (eslint's minimatch@3) No package.json ranges were changed and no Expo/framework versions were bumped or overridden - these are patch-level fixes already allowed by the existing dependency graph. Closes dependabot alerts #14, #13, #11, #8. Note: the following dependabot alerts remain open and are not fixable via a lockfile refresh: - #17, #16 (image-size DoS): no patched version exists upstream; image-size is archived and pulled in transitively via metro, even on the latest metro/expo releases. Needs an upstream fix in Metro. - #2 (uuid missing bounds check): the xcode package (used by @expo/config-plugins) pins uuid@^7.0.3 and has not bumped it in its latest release. Not practically exploitable here since xcode only calls uuid.v4() with no output buffer (the affected code path is v3()/v5()/v6() with a caller-supplied buffer). - #1 (esbuild dev server): comes from drizzle-kit's deprecated @esbuild-kit/esm-loader dependency, unrelated to Expo/Metro's dev server (already patched). Dev-only, low real-world risk since @esbuild-kit only uses esbuild's transform API, not serve().
This was referenced Oct 14, 2026
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
Adds an app-wide, on-device speech-to-text engine that keeps every clip in the library captioned, entirely on-device (no network beyond the one-time model download). The feature is surfaced through an On-device AI panel — a privacy-forward home-header entry point (sparkles + "AI") structured so future on-device features slot in alongside Captions. Users pick a Whisper model; the engine downloads it, transcribes the whole library in the background, and renders read-only captions in the in-recorder preview.
All work runs in a single global background engine mounted once at the root — it picks up new/imported/edited clips automatically and yields to the camera while recording so inference never competes with capture.
What's included
Engine —
src/features/transcription/TranscriptionProvider→useLibraryTranscription) mounted above all screens. Driven by the persisted model selection it: downloads the chosen model (keeping only one set of weights on disk), transcribes everything that needs it, and resumes work stranded by a killed app.whisper.ts— one reusable Whisper context. Runs with GPU/Metal + Flash Attention (falls back to CPU if the GPU can't init), decodes in the model's language, and emits caption-sized lines (maxLen+ token timestamps) instead of whole paragraphs.model.ts— on-demand model download with progress, completeness floor, shared in-flight downloads, single-model-on-disk enforcement, and cancellation of stale downloads on model switch.models.ts— catalog (Tiny/Base/Small English-only + Large Turbo multilingual) with an explicit per-model decode language.active-draft.ts/recording-signal.ts— lightweight module signals: caption the on-screen draft first, and yield while recording.Persistence —
src/db/transcriptstable: one row per segment, keyed by the effective file so a destructive edit invalidates and re-runs the transcript. Stores status (processing/done/error), language, text, and per-line timing JSON.settingsKV table (holds the selected model).0002+0003(verified withdrizzle-kit check).UI
model-switcher-modal.tsx) — reframed from a captions-only picker into a generalized "On-device AI" modal with a privacy-forward header and a Captions section (future on-device features slot in as additional sections). Pick/switch/delete a model, live download + transcription progress, and a confirm prompt before large (≥300 MB) downloads (cellular/data warning).preview-modal.tsx) — the active line synced to playback, plus "Transcribing…"/"unavailable" states.Correctness & robustness
langisenfor.enmodels,autofor Large Turbo.dirtyis set during engine teardown.Performance
Tooling / hygiene
whisper.rnto0.6.0(matches the repo's exact-pin convention); lockfile synced.__DEV__home-header seed buttons (+ seed / s2 / s3 / clear) moved into their own component loaded via a__DEV__-guardedrequire, so Metro's dead-code elimination drops both the component and@/dev/seed(with its perf-test fixtures) from the release bundle. Verified against a production iOS export: the dev string literals are absent from the Hermes bytecode while prod UI strings remain.babel-jest+@jest/globals,@/alias mapped). 17 unit tests covering the timeline math, the transcription decision/retry logic, and the model catalog (incl. a regression test locking in the language fix).npm test.Verification
tsc --noEmitexpo lintjest— 17/17drizzle-kit checkmaxLen: 42.Deliberately out of scope (follow-up)
mergeexposes no subtitle path, and burn-in defeats the stream-copy fast path (forces a re-encode). Planned separately.expo-battery.