Repository navigation
feat(mobile): pick the language voice input transcribes in #22380
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
Closed
Closed
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
7c956f0
feat(mobile): voice input can transcribe in a chosen language
GSTJ c78c6a2
feat(mobile): pick the dictation language in Settings
GSTJ c972b13
fix(mobile): keep Device language after other preference saves
GSTJ 40b2040
feat(mobile): native transcription module lists the languages the dev…
GSTJ 7b354f9
feat(mobile): dictation language picker lists what the device supports
GSTJ 564d1a4
Merge remote-tracking branch 'upstream/main' into feat/voice-transcri…
GSTJ 546c05a
fix(mobile): preserve dictation language extensions
GSTJ File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
47 changes: 47 additions & 0 deletions
47
apps/mobile/src/features/settings/SettingsDictationLanguageRouteScreen.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView"; | ||
| import { useAtomSet, useAtomValue } from "@effect/atom-react"; | ||
| import { AsyncResult } from "effect/reactivity"; | ||
| import { View } from "react-native"; | ||
| import { useSafeAreaInsets } from "react-native-safe-area-context"; | ||
|
|
||
| import { DEVICE_DICTATION_LANGUAGE_LABEL, DICTATION_LANGUAGES } from "../../lib/dictationLanguages"; | ||
| import { mobilePreferencesAtom, updateMobilePreferencesAtom } from "../../state/preferences"; | ||
| import { SettingsChoiceRow } from "./components/SettingsChoiceRow"; | ||
| import { SettingsSection } from "./components/SettingsSection"; | ||
|
|
||
| const OPTIONS = [{ id: null, label: DEVICE_DICTATION_LANGUAGE_LABEL }, ...DICTATION_LANGUAGES]; | ||
|
|
||
| export function SettingsDictationLanguageRouteScreen() { | ||
| const insets = useSafeAreaInsets(); | ||
| const preferencesResult = useAtomValue(mobilePreferencesAtom); | ||
| const savePreferences = useAtomSet(updateMobilePreferencesAtom); | ||
| const preferencesReady = AsyncResult.isSuccess(preferencesResult) && !preferencesResult.waiting; | ||
| const selectedId = AsyncResult.isSuccess(preferencesResult) | ||
| ? (preferencesResult.value.voiceInputLocale ?? null) | ||
| : undefined; | ||
|
|
||
| return ( | ||
| <View collapsable={false} className="flex-1 bg-sheet"> | ||
| <ScrollView | ||
| contentInsetAdjustmentBehavior="automatic" | ||
| showsVerticalScrollIndicator={false} | ||
| className="flex-1" | ||
| contentContainerClassName="gap-3 px-5 pt-4" | ||
| contentContainerStyle={{ paddingBottom: Math.max(insets.bottom, 18) + 18 }} | ||
| > | ||
| <SettingsSection footer="The language you speak when dictating."> | ||
| {OPTIONS.map((option, index) => ( | ||
| <SettingsChoiceRow | ||
| key={option.id ?? "device"} | ||
| label={option.label} | ||
| selected={selectedId === option.id} | ||
| separated={index > 0} | ||
| disabled={!preferencesReady} | ||
| onPress={() => savePreferences({ voiceInputLocale: option.id })} | ||
| /> | ||
| ))} | ||
| </SettingsSection> | ||
| </ScrollView> | ||
| </View> | ||
| ); | ||
| } |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { describe, expect, it } from "vite-plus/test"; | ||
|
|
||
| import { dictationLanguageLabel, isDictationLanguage } from "./dictationLanguages"; | ||
|
|
||
| describe("isDictationLanguage", () => { | ||
| it("accepts listed ids and rejects anything else", () => { | ||
| expect(isDictationLanguage("pt-BR")).toBe(true); | ||
| expect(isDictationLanguage("pt")).toBe(false); | ||
| expect(isDictationLanguage("xx-XX")).toBe(false); | ||
| expect(isDictationLanguage(42)).toBe(false); | ||
| }); | ||
| }); | ||
|
|
||
| describe("dictationLanguageLabel", () => { | ||
| it("names the chosen language and falls back to the device language", () => { | ||
| expect(dictationLanguageLabel("pt-BR")).toBe("Português (Brasil)"); | ||
| expect(dictationLanguageLabel(undefined)).toBe("Device language"); | ||
| }); | ||
| }); |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Every id is in SpeechTranscriber.supportedLocales on iOS 26. Labels are endonyms written out | ||
| // because Hermes's Intl.DisplayNames support is not guaranteed. | ||
| export const DICTATION_LANGUAGES: ReadonlyArray<{ readonly id: string; readonly label: string }> = [ | ||
| { id: "de-DE", label: "Deutsch (Deutschland)" }, | ||
| { id: "en-AU", label: "English (Australia)" }, | ||
| { id: "en-CA", label: "English (Canada)" }, | ||
| { id: "en-IN", label: "English (India)" }, | ||
| { id: "en-GB", label: "English (UK)" }, | ||
| { id: "en-US", label: "English (US)" }, | ||
| { id: "es-ES", label: "Español (España)" }, | ||
| { id: "es-US", label: "Español (Estados Unidos)" }, | ||
| { id: "es-MX", label: "Español (México)" }, | ||
| { id: "fr-CA", label: "Français (Canada)" }, | ||
| { id: "fr-FR", label: "Français (France)" }, | ||
| { id: "it-IT", label: "Italiano (Italia)" }, | ||
| { id: "pt-BR", label: "Português (Brasil)" }, | ||
| { id: "pt-PT", label: "Português (Portugal)" }, | ||
| { id: "hi-IN", label: "हिन्दी (भारत)" }, | ||
| { id: "ko-KR", label: "한국어(대한민국)" }, | ||
| { id: "zh-CN", label: "中文(中国大陆)" }, | ||
| { id: "zh-HK", label: "中文(香港)" }, | ||
| { id: "zh-TW", label: "中文(台灣)" }, | ||
| { id: "ja-JP", label: "日本語 (日本)" }, | ||
| { id: "yue-CN", label: "粤语(中国大陆)" }, | ||
| ]; | ||
|
|
||
| export const DEVICE_DICTATION_LANGUAGE_LABEL = "Device language"; | ||
|
|
||
| export function isDictationLanguage(value: unknown): value is string { | ||
| return DICTATION_LANGUAGES.some((language) => language.id === value); | ||
| } | ||
|
|
||
| export function dictationLanguageLabel(id: string | null | undefined): string { | ||
| return ( | ||
| DICTATION_LANGUAGES.find((language) => language.id === id)?.label ?? | ||
| DEVICE_DICTATION_LANGUAGE_LABEL | ||
| ); | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import type { VoiceTranscriber } from "@t3tools/client-runtime/voice-input"; | ||
|
|
||
| export function getLocalVoiceTranscriber(): VoiceTranscriber | null { | ||
| export function getLocalVoiceTranscriber(_preferredLocale?: string): VoiceTranscriber | null { | ||
| return null; | ||
| } |
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.