Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(mobile): transcribe voice input in the user's language #13312

Closednichtlegacy(GitHub profile, opens in a new tab)wants to merge 4 commits intomain fromrefs/pull/13312/headopened View on GitHub

Showing 5 changed files with 67 additions and 5 deletions (loading 2).

x
0 of 5 viewed, 5 left
36 additions and 0 deletionsapps/mobile/src/native/voiceTranscription.ios.test.tsModified
View file
@@ -8,8 +8,11 @@
prepare: vi.fn<(locale: string) => Promise<string>>(),
transcribe: vi.fn<(audio: ArrayBufferLike, locale: string) => Promise<TranscriptionResult>>(),
readAudio: vi.fn<() => Promise<ArrayBuffer>>(),
+ getSetting: vi.fn<(key: string) => unknown>(),
}));
​
+vi.mock("react-native", () => ({ Settings: { get: mocks.getSetting } }));
+​
vi.mock("@react-native-ai/apple/src/NativeAppleTranscription", () => ({
default: {
isAvailable: mocks.isAvailable,
@@ -74,6 +77,39 @@
expect(mocks.transcribe).toHaveBeenCalledWith(audio, "sv-SE");
});
​
+ it("prefers the user's languages over the English-only app locale", async () => {
+ const resolvedOptions = Intl.DateTimeFormat().resolvedOptions();
+ vi.spyOn(Intl.DateTimeFormat.prototype, "resolvedOptions").mockReturnValue({
+ ...resolvedOptions,
+ locale: "en-DE",
+ });
+ mocks.getSetting.mockReturnValue(["de-DE", "en-US"]);
+ mocks.prepare.mockResolvedValue("de_DE");
+​
+ const prepared = await getLocalVoiceTranscriber()!.prepare({
+ signal: new AbortController().signal,
+ });
+​