Repository navigation
feat(mobile): voice settings show which on-device speech engine runs #33712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
12b3241
25572f4
3d4043d
a0437a4
12ee237
9b8cd5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,17 @@ | ||
| import { msg, useGT, useMessages } from "gt-react-native"; | ||
| import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView"; | ||
| import { useAtomSet, useAtomValue } from "@effect/atom-react"; | ||
| import { useAtomRefresh, useAtomSet, useAtomValue } from "@effect/atom-react"; | ||
| import { AsyncResult } from "effect/reactivity"; | ||
| import { getRecordingPermissionsAsync, requestRecordingPermissionsAsync } from "expo-audio"; | ||
| import { useState } from "react"; | ||
| import { useEffect, useState } from "react"; | ||
| import { Linking, Platform, useWindowDimensions, View } from "react-native"; | ||
| import Reanimated, { ReduceMotion, useAnimatedStyle, withTiming } from "react-native-reanimated"; | ||
| import { useSafeAreaInsets } from "react-native-safe-area-context"; | ||
|
|
||
| import { type AppSymbolName } from "../../components/ui/AppSymbol"; | ||
| import { AppText as Text } from "../../components/ui/AppText"; | ||
| import { cn } from "../../lib/cn"; | ||
| import { m } from "../../i18n/messages"; | ||
| import { m, type MessageResolver } from "../../i18n/messages"; | ||
| import { makePermissionStatusAtom } from "../../lib/permissionStatusAtom"; | ||
| import { | ||
| isMicrophoneDevice, | ||
|
|
@@ -35,6 +35,7 @@ import { LocalModelChoice } from "./VoiceModelSection"; | |
| import { CloudVoiceChoice } from "./CloudVoiceSection"; | ||
| import type { VoiceGrant } from "../voice-input/voiceGrantStorage"; | ||
| import type { EnvironmentId } from "@t3tools/contracts"; | ||
| import { type LocalVoiceEngine } from "../../native/voiceTranscription"; | ||
| import { ThreadSwipeable } from "../home/thread-swipe-actions"; | ||
| import { ListActionRow as SettingsActionRow } from "../../components/ui/ListActionRow"; | ||
| import { SettingsDragHandle } from "./components/SettingsDragHandle"; | ||
|
|
@@ -120,6 +121,24 @@ const UNAVAILABLE_EXPLANATION = | |
| "Dictation on this device needs iOS 26 or later, a supported device, and a supported language. Your keyboard’s dictation is separate.", | ||
| ); | ||
|
|
||
| const LOCAL_ENGINE_EXPLANATION = | ||
| Platform.OS === "android" | ||
| ? msg( | ||
| "Basic is Google’s standard speech model. Advanced uses Gemini Nano on supported phones and is usually more accurate. Your keyboard’s voice typing is separate.", | ||
| ) | ||
| : msg("Your keyboard’s dictation is separate."); | ||
|
|
||
| function localEngineLabel(engine: LocalVoiceEngine, resolve: MessageResolver) { | ||
| if (engine.kind === "apple") return resolve(msg("Apple on-device speech")); | ||
| const language = engine.downloaded ? engine.language : resolve(msg("Downloads on first use")); | ||
| return resolve( | ||
| msg("Google on-device speech · {mode} · {language}", { | ||
| mode: engine.advanced ? resolve(msg("Advanced")) : resolve(msg("Basic")), | ||
| language, | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| function saveDestination(id: EnvironmentId | null) { | ||
| try { | ||
| chooseVoiceDestination(id); | ||
|
|
@@ -222,6 +241,13 @@ export function SettingsVoiceRouteScreen() { | |
| const gt = useGT(); | ||
| const m = useMessages(); | ||
| const transcriber = useAtomValue(localVoiceTranscriberAtom); | ||
| const refreshTranscriber = useAtomRefresh(localVoiceTranscriberAtom); | ||
| // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- dictation can download a model, so re-probe the native engine without a "checking" flash | ||
| useEffect(() => { | ||
| refreshTranscriber(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep the last working local transcriber when a re-probe rejects. A failed re-probe currently replaces a working local transcriber with The new Settings mount refresh adds another trigger for this write. Only a settled unsupported result should clear the local transcriber. A rejected probe should leave the prior working transcriber in place.
|
||
| }, [refreshTranscriber]); | ||
| const localEngine = | ||
| transcriber === null || transcriber === "checking" ? null : transcriber.engine; | ||
|
RVZO6 marked this conversation as resolved.
Resolved
|
||
| const grant = useAtomValue(voiceGrantAtom); | ||
| const { environments, isReady } = useEnvironments(); | ||
| const grantEnvironment = grant | ||
|
|
@@ -293,10 +319,25 @@ export function SettingsVoiceRouteScreen() { | |
| contentContainerClassName="gap-3 px-5 pt-4" | ||
| contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }} | ||
| > | ||
| <SettingsSection title={gt("Transcribe on")}> | ||
| <SettingsSection | ||
| title={gt("Transcribe on")} | ||
| footer={localEngine ? m(LOCAL_ENGINE_EXPLANATION) : undefined} | ||
| > | ||
| <ListChoiceRow | ||
| label={gt("This device")} | ||
| accessibilityLabel={ | ||
| localEngine | ||
| ? gt("This device, {engine}", { engine: localEngineLabel(localEngine, m) }) | ||
| : undefined | ||
| } | ||
| description={gt("Audio stays on this device and is transcribed here.")} | ||
| meta={ | ||
| localEngine ? ( | ||
| <Text textRole="footnote" className="text-foreground"> | ||
| {localEngineLabel(localEngine, m)} | ||
| </Text> | ||
| ) : undefined | ||
| } | ||
| selected={!grant && !sheetEnvironment} | ||
| onPress={() => { | ||
| setCloudSheet(null); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.