diff --git a/apps/mobile/src/features/settings/CloudVoiceSection.tsx b/apps/mobile/src/features/settings/CloudVoiceSection.tsx index 3e782d2457fa3..b396a6bd246d8 100644 --- a/apps/mobile/src/features/settings/CloudVoiceSection.tsx +++ b/apps/mobile/src/features/settings/CloudVoiceSection.tsx @@ -27,6 +27,7 @@ import { ScrollView, TextInput, View } from "react-native"; import { Sheet } from "../../components/ui/Sheet"; import * as Dialog from "../../components/ui/Dialog"; import { ProviderIcon } from "../../components/ProviderIcon"; +import { SymbolView } from "../../components/ui/AppSymbol"; import { AppText as Text } from "../../components/ui/AppText"; import { ListActionRow } from "../../components/ui/ListActionRow"; import { ListChoiceRow } from "../../components/ui/ListChoiceRow"; @@ -300,12 +301,16 @@ function CloudChoices({ environment, active, onClose }: Props & { onClose: () => key={provider} label={label} leading={ - + provider === "deepgram" ? ( + + ) : ( + + ) } selected={isActive} separated={index > 0} diff --git a/apps/server/src/serverSettings.test.ts b/apps/server/src/serverSettings.test.ts index 5d46c916c3990..3650ebc394cca 100644 --- a/apps/server/src/serverSettings.test.ts +++ b/apps/server/src/serverSettings.test.ts @@ -1783,7 +1783,11 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("server settings" const hub = UsageLimitSourceId.make("hub"); const router = ProviderInstanceId.make("openrouter"); const withUsage = yield* serverSettings.updateSettings({ - cloudSpeechCredentials: { openai: usageReference, xai: "literal-fixture" }, + cloudSpeechCredentials: { + openai: usageReference, + xai: "literal-fixture", + deepgram: usageReference, + }, textGenerators: { [router]: { kind: "openaiCompatible", @@ -1841,6 +1845,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("server settings" openai: SECRET_REDACTED, xai: SECRET_REDACTED, openrouter: "", + deepgram: SECRET_REDACTED, }); assert.equal(legacy.sourceControlHosts.bitbucket?.accessToken, SECRET_REDACTED); assert.equal(legacy.usageLimitSources[hub]?.managementKey, SECRET_REDACTED); @@ -1871,6 +1876,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("server settings" openai: usageReference, xai: "literal-fixture", openrouter: "", + deepgram: usageReference, }); assert.deepEqual(echoed.easDeviceHosts[0]?.accessToken, easReference); assert.deepEqual(echoed.simlockDeviceHosts[0]?.agentToken, simlockReference); @@ -1974,7 +1980,12 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("server settings" "ghe.acme.test": work, }); assert.equal(removed.usageLimitSources[hub]?.managementKey, ""); - assert.deepEqual(removed.cloudSpeechCredentials, { openai: "", xai: work, openrouter: "" }); + assert.deepEqual(removed.cloudSpeechCredentials, { + openai: "", + xai: work, + openrouter: "", + deepgram: "", + }); assert.equal(removed.easDeviceHosts[0]?.accessToken, ""); assert.deepEqual(Object.keys(removed.secretProviders), ["work"]); }).pipe(Effect.provide(layerServerSettingsWithSecrets())), @@ -1987,6 +1998,7 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("server settings" "cloudSpeechCredentials.openai", "cloudSpeechCredentials.xai", "cloudSpeechCredentials.openrouter", + "cloudSpeechCredentials.deepgram", "easDeviceHosts.[].accessToken", "simlockDeviceHosts.[].agentToken", "usageLimitSources.*.managementKey", diff --git a/apps/server/src/sourceControl/sourceControlHostSecrets.test.ts b/apps/server/src/sourceControl/sourceControlHostSecrets.test.ts index 9f73b2512841c..8b0af2d3601ba 100644 --- a/apps/server/src/sourceControl/sourceControlHostSecrets.test.ts +++ b/apps/server/src/sourceControl/sourceControlHostSecrets.test.ts @@ -176,7 +176,12 @@ it.effect("reads a collected reference again once it is invalidated", () => resolver, Effect.succeed({ sourceControlHosts: hosts, - cloudSpeechCredentials: { openai: source("voice#key"), xai: "", openrouter: "" }, + cloudSpeechCredentials: { + openai: source("voice#key"), + xai: "", + openrouter: "", + deepgram: "", + }, usageLimitSources, textGenerators: {}, easDeviceHosts, diff --git a/apps/server/src/speech/CloudSpeech.test.ts b/apps/server/src/speech/CloudSpeech.test.ts index 1ada861d6d852..3172cf8634697 100644 --- a/apps/server/src/speech/CloudSpeech.test.ts +++ b/apps/server/src/speech/CloudSpeech.test.ts @@ -52,7 +52,12 @@ it.effect.each(["openai", "xai"] as const)("sends only to %s using its own saved yield* service.setKey(provider === "openai" ? "xai" : "openai", Redacted.make("other")); expect((yield* Effect.flip(transcribe()))._tag).toBe("CloudSpeechError"); yield* service.setKey(provider, Redacted.make("chosen")); - expect(yield* service.configured).toEqual({ openai: true, xai: true, openrouter: false }); + expect(yield* service.configured).toEqual({ + openai: true, + xai: true, + openrouter: false, + deepgram: false, + }); yield* Effect.flip(transcribe(new Uint8Array(3))); expect(upstream).not.toHaveBeenCalled(); expect(yield* transcribe()).toBe("hello"); @@ -166,6 +171,87 @@ it.effect("uploads to OpenRouter only for a listed exact model, as zero-retentio }), ); +it.effect("sends Deepgram raw WAV with its token and reads the first transcript", () => + Effect.gen(function* () { + const upstream = vi.fn(async () => + Response.json({ results: { channels: [{ alternatives: [{ transcript: "hello" }] }] } }), + ); + const service = yield* CloudSpeech.CloudSpeech.pipe( + Effect.provide( + CloudSpeech.layer.pipe( + Layer.provide(FetchHttpClient.layer), + Layer.provide(ServerSettings.ServerSettingsService.layerTest()), + Layer.provide(Layer.mock(SecretResolver.SecretResolver)({})), + ), + ), + ); + const transcribe = (speechLanguage: string) => + service + .transcribe("deepgram", new Uint8Array(new Float32Array([0, 0.5]).buffer), { + ...DEFAULT_SPEECH_TRANSCRIPTION_OPTIONS, + speechLanguage, + speechCustomWords: [{ term: "T3 Code", aliases: [] }], + }) + .pipe(Effect.provideService(FetchHttpClient.Fetch, upstream)); + yield* service.setKey("deepgram", Redacted.make("dg-key")); + expect((yield* service.configured).deepgram).toBe(true); + expect(yield* transcribe("ru")).toBe("hello"); + const [url, init] = upstream.mock.calls[0]!; + const sent = new URL(String(url)); + expect(sent.origin + sent.pathname).toBe("https://api.deepgram.com/v1/listen"); + expect(sent.searchParams.get("model")).toBe("nova-3"); + expect(sent.searchParams.get("redact_usage")).toBe("true"); + expect(sent.searchParams.get("language")).toBe("ru"); + expect(sent.searchParams.getAll("keyterm")).toEqual(["T3 Code"]); + expect(init?.redirect).toBe("error"); + const headers = new Headers(init?.headers); + expect(headers.get("authorization")).toBe("Token dg-key"); + expect(headers.get("content-type")).toBe("audio/wav"); + const wav = Buffer.from(yield* Effect.promise(() => new Response(init?.body).arrayBuffer())); + expect(wav.toString("ascii", 0, 4)).toBe("RIFF"); + expect(wav.readInt16LE(46)).toBe(16384); + yield* transcribe("auto"); + expect(new URL(String(upstream.mock.calls[1]![0])).searchParams.get("language")).toBe("multi"); + const keytermLimit = () => + Response.json( + { + err_code: "Bad Request", + err_msg: + "Bad Request: Keyterm limit exceeded. The maximum number of tokens across all keyterms is 500.", + }, + { status: 400 }, + ); + upstream.mockResolvedValueOnce(keytermLimit()); + expect(yield* transcribe("en")).toBe("hello"); + const [limited, retried] = upstream.mock.calls.slice(-2).map(([url]) => new URL(String(url))); + expect(limited!.searchParams.getAll("keyterm")).toEqual(["T3 Code"]); + expect(retried!.searchParams.has("keyterm")).toBe(false); + upstream.mockResolvedValueOnce(new Response("Bad Request", { status: 400 })); + expect(yield* Effect.flip(transcribe("en"))).toMatchObject({ reason: "unavailable" }); + upstream.mockResolvedValueOnce(new Response(null, { status: 402 })); + expect(yield* Effect.flip(transcribe("en"))).toMatchObject({ + provider: "deepgram", + reason: "rejected-key", + }); + upstream.mockResolvedValueOnce(Response.json({ results: { channels: [] } })); + expect(yield* Effect.flip(transcribe("en"))).toMatchObject({ reason: "unavailable" }); + // Removing the key during the first upload must stop the keyterm-free retry. + const uploadStarted = Promise.withResolvers(); + const rejection = Promise.withResolvers(); + upstream.mockImplementationOnce(() => { + uploadStarted.resolve(); + return rejection.promise; + }); + const uploads = upstream.mock.calls.length; + const job = yield* transcribe("en").pipe(Effect.forkChild); + yield* Effect.promise(() => uploadStarted.promise); + yield* service.setKey("deepgram", null); + rejection.resolve(keytermLimit()); + expect(yield* Effect.flip(Fiber.join(job))).toMatchObject({ reason: "missing-key" }); + expect(upstream).toHaveBeenCalledTimes(uploads + 1); + }), +); + it.effect("removing a key while a catalog read is pending prevents the upload", () => Effect.gen(function* () { const service = yield* CloudSpeech.CloudSpeech.pipe( diff --git a/apps/server/src/speech/CloudSpeech.ts b/apps/server/src/speech/CloudSpeech.ts index 31702c80a87ee..66d3ff40918f3 100644 --- a/apps/server/src/speech/CloudSpeech.ts +++ b/apps/server/src/speech/CloudSpeech.ts @@ -31,12 +31,22 @@ const endpoints = { openai: { url: "https://api.openai.com/v1/audio/transcriptions", model: "gpt-transcribe" }, xai: { url: "https://api.x.ai/v1/stt", model: "grok-voice-transcribe-2.0" }, openrouter: { url: "https://openrouter.ai/api/v1/audio/transcriptions" }, + deepgram: { url: "https://api.deepgram.com/v1/listen", model: "nova-3" }, }; const OPENROUTER_CATALOG_URL = "https://openrouter.ai/api/v1/models?output_modalities=transcription&zdr=true"; const isApiKey = Schema.is(CloudSpeechApiKey); const isModelId = Schema.is(CloudSpeechModelId); const sameCredential = Schema.toEquivalence(SettingsSecretValue); +const DeepgramResult = Schema.Struct({ + results: Schema.Struct({ + channels: Schema.NonEmptyArray( + Schema.Struct({ + alternatives: Schema.NonEmptyArray(Schema.Struct({ transcript: Schema.String })), + }), + ), + }), +}); const OpenRouterCatalog = Schema.Struct({ data: Schema.Array(Schema.Struct({ id: Schema.String, name: Schema.optionalKey(Schema.String) })), }); @@ -104,6 +114,20 @@ function openRouterBody(model: string, audio: ArrayBuffer, language: string) { }); } +function deepgramUrl(language: string, options: SpeechTranscriptionOptions, keyterms: boolean) { + const url = new URL(endpoints.deepgram.url); + url.searchParams.set("model", endpoints.deepgram.model); + url.searchParams.set("smart_format", "true"); + url.searchParams.set("redact_usage", "true"); + // `multi` transcribes speech that switches languages, such as English terms in other speech. + url.searchParams.set("language", language === "auto" ? "multi" : language); + if (keyterms) + for (const { term } of options.speechCustomWords) url.searchParams.append("keyterm", term); + if (!options.speechRemoveFillerWords || options.speechCorrectionWord) + url.searchParams.set("filler_words", "true"); + return url; +} + export class CloudSpeech extends Context.Service< CloudSpeech, { @@ -133,10 +157,11 @@ export const layer = Layer.effect( Effect.map((value) => value.cloudSpeechCredentials), ); const configured = credentials.pipe( - Effect.map(({ openai, xai, openrouter }) => ({ + Effect.map(({ openai, xai, openrouter, deepgram }) => ({ openai: Boolean(openai), xai: Boolean(xai), openrouter: Boolean(openrouter), + deepgram: Boolean(deepgram), })), ); const execute = (request: HttpClientRequest.HttpClientRequest) => @@ -211,21 +236,42 @@ export const layer = Layer.effect( ); if (!isApiKey(key)) return yield* unreadable(); const audio = wave(samples); - const request = HttpClientRequest.post(endpoints[provider].url).pipe( - HttpClientRequest.bearerToken(Redacted.make(key)), - provider === "openrouter" - ? openRouterBody(model!, audio, language) - : audioBody(provider, audio, language, options), - ); + const deepgramRequest = (keyterms: boolean) => + HttpClientRequest.post(deepgramUrl(language, options, keyterms)).pipe( + HttpClientRequest.setHeader("authorization", `Token ${key}`), + HttpClientRequest.bodyUint8Array(new Uint8Array(audio), "audio/wav"), + ); + const request = + provider === "deepgram" + ? deepgramRequest(true) + : HttpClientRequest.post(endpoints[provider].url).pipe( + HttpClientRequest.bearerToken(Redacted.make(key)), + provider === "openrouter" + ? openRouterBody(model!, audio, language) + : audioBody(provider, audio, language, options), + ); const unavailable = () => new CloudSpeechError({ provider, reason: "unavailable" }); - // A catalog fetch or vault lookup may have outlived the credential it started with. - const current = (yield* credentials)[provider]; - if (!current || !sameCredential(source, current)) - return yield* new CloudSpeechError({ - provider, - reason: current ? "key-changed" : "missing-key", - }); - const response = yield* execute(request).pipe(Effect.mapError(unavailable)); + // A catalog fetch, vault lookup, or earlier upload may have outlived the credential. + const ensureCurrentKey = Effect.gen(function* () { + const current = (yield* credentials)[provider]; + if (!current || !sameCredential(source, current)) + return yield* new CloudSpeechError({ + provider, + reason: current ? "key-changed" : "missing-key", + }); + }); + yield* ensureCurrentKey; + let response = yield* execute(request).pipe(Effect.mapError(unavailable)); + // Deepgram caps keyterms in tokens clients cannot count; the dictionary still fixes the text below. + if ( + provider === "deepgram" && + response.status === 400 && + options.speechCustomWords.length > 0 && + (yield* response.text.pipe(Effect.orElseSucceed(() => ""))).includes("Keyterm limit") + ) { + yield* ensureCurrentKey; + response = yield* execute(deepgramRequest(false)).pipe(Effect.mapError(unavailable)); + } if (response.status < 200 || response.status >= 300) return yield* new CloudSpeechError({ provider, @@ -238,9 +284,14 @@ export const layer = Layer.effect( ? "model-unavailable" : "unavailable", }); - const { text } = yield* HttpClientResponse.schemaBodyJson( - EnvironmentSpeechTranscriptionResult, - )(response).pipe(Effect.mapError(unavailable)); + const text = + provider === "deepgram" + ? (yield* HttpClientResponse.schemaBodyJson(DeepgramResult)(response).pipe( + Effect.mapError(unavailable), + )).results.channels[0].alternatives[0].transcript + : (yield* HttpClientResponse.schemaBodyJson(EnvironmentSpeechTranscriptionResult)( + response, + ).pipe(Effect.mapError(unavailable))).text; const corrected = applySpeechAliases(text, options.speechCustomWords); return ( options.speechRemoveFillerWords diff --git a/apps/web/src/components/settings/CloudVoiceConfiguration.browser.test.tsx b/apps/web/src/components/settings/CloudVoiceConfiguration.browser.test.tsx index f859695e3360d..545e8e1b7811d 100644 --- a/apps/web/src/components/settings/CloudVoiceConfiguration.browser.test.tsx +++ b/apps/web/src/components/settings/CloudVoiceConfiguration.browser.test.tsx @@ -98,8 +98,14 @@ it("cancelling a provider's setup keeps the current destination and writes nothi const destination = screen.getByRole("combobox", { name: "Transcribe with" }); await expect.element(destination).toHaveTextContent("Laptop"); await destination.click(); - await page.getByRole("option", { name: "OpenAI via Laptop" }).click(); + await page.getByRole("option", { name: "Deepgram via Laptop" }).click(); const dialog = page.getByRole("dialog"); + await expect + .element(dialog.getByText("Update Laptop to use Deepgram dictation.")) + .toBeVisible(); + await dialog.getByRole("button", { name: "Cancel" }).click(); + await destination.click(); + await page.getByRole("option", { name: "OpenAI via Laptop" }).click(); await dialog.getByRole("button", { name: "Cancel" }).click(); await expect.element(dialog).not.toBeInTheDocument(); await expect.element(destination).toHaveTextContent("Laptop"); diff --git a/apps/web/src/components/settings/CloudVoiceConfiguration.tsx b/apps/web/src/components/settings/CloudVoiceConfiguration.tsx index 0a992f4f93b61..bdce8814b1c0b 100644 --- a/apps/web/src/components/settings/CloudVoiceConfiguration.tsx +++ b/apps/web/src/components/settings/CloudVoiceConfiguration.tsx @@ -228,7 +228,7 @@ export function CloudVoiceConfiguration({ const destination = (): CloudDestination => routed && isModelId(model) ? { kind: "cloud", provider: "openrouter", environmentId: id, model } - : { kind: "cloud", provider: provider as "openai" | "xai", environmentId: id }; + : { kind: "cloud", provider: provider as "openai" | "xai" | "deepgram", environmentId: id }; const enable = () => chooseAudioDestination(destination()); const canSubmit = routed ? modelChosen && keyReady && (!active || modelChanged || keyChanged) @@ -367,13 +367,10 @@ export function CloudVoiceConfiguration({ - ) : routed && - AsyncResult.isSuccess(presence) && - presence.value && - saved === undefined ? ( + ) : AsyncResult.isSuccess(presence) && presence.value && saved === undefined ? (

- Update {environment.label} to use OpenRouter dictation. + Update {environment.label} to use {name} dictation.

) : saved === undefined ? ( diff --git a/apps/web/src/components/settings/VoiceSettingsPanel.tsx b/apps/web/src/components/settings/VoiceSettingsPanel.tsx index 84a76f373c8be..f88740d214b1f 100644 --- a/apps/web/src/components/settings/VoiceSettingsPanel.tsx +++ b/apps/web/src/components/settings/VoiceSettingsPanel.tsx @@ -151,6 +151,7 @@ import { useScopedSettings, useUpdateScopedSettings } from "./useScopedSettings" const OFF = "off"; const DEVICE = "device"; function CloudSpeechLogo({ provider }: { provider: CloudSpeechProvider }) { + if (provider === "deepgram") return ; if (provider === "openrouter") return ; return ( diff --git a/apps/web/src/components/settings/settingsSearch.ts b/apps/web/src/components/settings/settingsSearch.ts index 4f57b8d730842..578d76477162a 100644 --- a/apps/web/src/components/settings/settingsSearch.ts +++ b/apps/web/src/components/settings/settingsSearch.ts @@ -591,6 +591,7 @@ export const SETTINGS_SEARCH_ITEMS = [ msg( "send microphone audio dictation destination speech voice stt transcription environment machine consent privacy cloud OpenAI Grok OpenRouter", ), + "Deepgram", ], }, { diff --git a/apps/web/src/i18n/translations/de.json b/apps/web/src/i18n/translations/de.json index 8d5cb7d817bb1..d5a53d546627b 100644 --- a/apps/web/src/i18n/translations/de.json +++ b/apps/web/src/i18n/translations/de.json @@ -7910,14 +7910,20 @@ ", um fortzufahren." ], "1d33877ef8ea3559": "Laden des API-Schlüssels wiederholen", - "be805c1729dc0726": [ + "2b5b356019c6857b": [ "Aktualisiere ", { "i": 1, "k": "_gt_value_1", "v": "v" }, - ", um OpenRouter-Diktat zu nutzen." + ", um ", + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "-Diktat zu nutzen." ], "d7acad5dde4c1d1b": "Es wird nach einem API-Schlüssel gesucht…", "8257030da7a4ad4e": "Modell", diff --git a/apps/web/src/i18n/translations/en.json b/apps/web/src/i18n/translations/en.json index 6c5ef49b77f43..dfac897f489d5 100644 --- a/apps/web/src/i18n/translations/en.json +++ b/apps/web/src/i18n/translations/en.json @@ -7917,14 +7917,20 @@ " with dictation access to continue." ], "1d33877ef8ea3559": "Retry loading API key", - "be805c1729dc0726": [ + "2b5b356019c6857b": [ "Update ", { "i": 1, "k": "_gt_value_1", "v": "v" }, - " to use OpenRouter dictation." + " to use ", + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + " dictation." ], "d7acad5dde4c1d1b": "Checking for an API key…", "8257030da7a4ad4e": "Model", diff --git a/apps/web/src/i18n/translations/es.json b/apps/web/src/i18n/translations/es.json index 1f4ed2cf548ee..250a1f3fdeb2b 100644 --- a/apps/web/src/i18n/translations/es.json +++ b/apps/web/src/i18n/translations/es.json @@ -7909,14 +7909,20 @@ " con acceso al dictado para continuar." ], "1d33877ef8ea3559": "Reintentar la carga de la clave de API", - "be805c1729dc0726": [ + "2b5b356019c6857b": [ "Actualiza ", { "i": 1, "k": "_gt_value_1", "v": "v" }, - " para usar el dictado con OpenRouter." + " para usar el dictado de ", + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "." ], "d7acad5dde4c1d1b": "Buscando una clave de API…", "8257030da7a4ad4e": "Modelo", diff --git a/apps/web/src/i18n/translations/fr.json b/apps/web/src/i18n/translations/fr.json index 72da8bf8e23b2..0f5bd0a56d208 100644 --- a/apps/web/src/i18n/translations/fr.json +++ b/apps/web/src/i18n/translations/fr.json @@ -7910,14 +7910,20 @@ " avec l’accès à la dictée pour continuer." ], "1d33877ef8ea3559": "Réessayer de charger la clé API", - "be805c1729dc0726": [ + "2b5b356019c6857b": [ "Mettez à jour ", { "i": 1, "k": "_gt_value_1", "v": "v" }, - " pour utiliser la dictée OpenRouter." + " pour utiliser la dictée ", + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "." ], "d7acad5dde4c1d1b": "Recherche d’une clé API…", "8257030da7a4ad4e": "Modèle", diff --git a/apps/web/src/i18n/translations/ja.json b/apps/web/src/i18n/translations/ja.json index 28945ae29dca3..6d2d6438f638e 100644 --- a/apps/web/src/i18n/translations/ja.json +++ b/apps/web/src/i18n/translations/ja.json @@ -7874,8 +7874,13 @@ " に接続してください。" ], "1d33877ef8ea3559": "API キーの読み込みを再試行", - "be805c1729dc0726": [ - "OpenRouter の音声入力を使うには ", + "2b5b356019c6857b": [ + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + " の音声入力を使うには ", { "i": 1, "k": "_gt_value_1", diff --git a/apps/web/src/i18n/translations/ko.json b/apps/web/src/i18n/translations/ko.json index 35f6cc3549436..f391eb2e381bd 100644 --- a/apps/web/src/i18n/translations/ko.json +++ b/apps/web/src/i18n/translations/ko.json @@ -7876,8 +7876,13 @@ "에 연결하세요." ], "1d33877ef8ea3559": "API 키 다시 불러오기", - "be805c1729dc0726": [ - "OpenRouter 받아쓰기를 사용하려면 ", + "2b5b356019c6857b": [ + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + " 받아쓰기를 사용하려면 ", { "i": 1, "k": "_gt_value_1", diff --git a/apps/web/src/i18n/translations/pt-BR.json b/apps/web/src/i18n/translations/pt-BR.json index 85fefb672d30c..e3b60d29721b4 100644 --- a/apps/web/src/i18n/translations/pt-BR.json +++ b/apps/web/src/i18n/translations/pt-BR.json @@ -7909,14 +7909,20 @@ " com acesso ao ditado para continuar." ], "1d33877ef8ea3559": "Tentar carregar a chave de API novamente", - "be805c1729dc0726": [ + "2b5b356019c6857b": [ "Atualize ", { "i": 1, "k": "_gt_value_1", "v": "v" }, - " para usar o ditado do OpenRouter." + " para usar o ditado do ", + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "." ], "d7acad5dde4c1d1b": "Verificando se há uma chave de API…", "8257030da7a4ad4e": "Modelo", diff --git a/apps/web/src/i18n/translations/ru.json b/apps/web/src/i18n/translations/ru.json index f4d45a79d0b52..a238294a8f762 100644 --- a/apps/web/src/i18n/translations/ru.json +++ b/apps/web/src/i18n/translations/ru.json @@ -7909,14 +7909,20 @@ " с доступом к диктовке, чтобы продолжить." ], "1d33877ef8ea3559": "Повторить загрузку API-ключа", - "be805c1729dc0726": [ + "2b5b356019c6857b": [ "Обновите ", { "i": 1, "k": "_gt_value_1", "v": "v" }, - ", чтобы использовать диктовку OpenRouter." + ", чтобы использовать диктовку ", + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "." ], "d7acad5dde4c1d1b": "Проверка наличия API-ключа…", "8257030da7a4ad4e": "Модель", diff --git a/apps/web/src/i18n/translations/sv.json b/apps/web/src/i18n/translations/sv.json index 99818c1f2ed37..a7318c0e35582 100644 --- a/apps/web/src/i18n/translations/sv.json +++ b/apps/web/src/i18n/translations/sv.json @@ -7915,14 +7915,20 @@ " med dikteringsåtkomst för att fortsätta." ], "1d33877ef8ea3559": "Försök läsa in API-nyckeln igen", - "be805c1729dc0726": [ + "2b5b356019c6857b": [ "Uppdatera ", { "i": 1, "k": "_gt_value_1", "v": "v" }, - " för att använda diktering med OpenRouter." + " för att använda diktering med ", + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + "." ], "d7acad5dde4c1d1b": "Söker efter en API-nyckel…", "8257030da7a4ad4e": "Modell", diff --git a/apps/web/src/i18n/translations/zh.json b/apps/web/src/i18n/translations/zh.json index 09d04201cd2f8..6a7df998d987e 100644 --- a/apps/web/src/i18n/translations/zh.json +++ b/apps/web/src/i18n/translations/zh.json @@ -7927,14 +7927,20 @@ " 以继续。" ], "1d33877ef8ea3559": "重新加载 API 密钥", - "be805c1729dc0726": [ + "2b5b356019c6857b": [ "请更新 ", { "i": 1, "k": "_gt_value_1", "v": "v" }, - " 以使用 OpenRouter 听写。" + " 以使用 ", + { + "i": 2, + "k": "_gt_value_2", + "v": "v" + }, + " 听写。" ], "d7acad5dde4c1d1b": "正在检查 API 密钥…", "8257030da7a4ad4e": "模型", diff --git a/docs/user/voice-input.md b/docs/user/voice-input.md index 9831eeafd49f8..19abbaad4bcfc 100644 --- a/docs/user/voice-input.md +++ b/docs/user/voice-input.md @@ -31,8 +31,8 @@ recording in a language can take longer while macOS downloads its speech model. filler-word removal are not available; the dictionary applies only when transcript cleanup is on. -For cloud dictation, choose **OpenAI** or **Grok Voice Transcribe** via the environment -you want to use. If it needs a key, enter one and choose **Save and enable**. +For cloud dictation, choose **OpenAI**, **Grok Voice Transcribe**, or **Deepgram** via the +environment you want to use. If it needs a key, enter one and choose **Save and enable**. You can also choose a [secret provider](secrets.md) instead of **Value** and enter a reference. Unlock the vault on that environment before dictating. Anyone with dictation access to the environment can use the key, but only this device opts in. diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts index 4538065ee5c50..c83bd217e12f8 100644 --- a/packages/contracts/src/settings.ts +++ b/packages/contracts/src/settings.ts @@ -398,7 +398,7 @@ export const VoiceTranscriptionDestination = Schema.Union([ Schema.Struct({ kind: Schema.Literal("cloud"), environmentId: EnvironmentId, - provider: Schema.Literals(["openai", "xai"]), + provider: Schema.Literals(["openai", "xai", "deepgram"]), }), Schema.Struct({ kind: Schema.Literal("cloud"), @@ -1375,6 +1375,7 @@ export const CloudSpeechCredentials = Schema.Struct({ openai: CloudSpeechCredential, xai: CloudSpeechCredential, openrouter: CloudSpeechCredential, + deepgram: CloudSpeechCredential, }); export const ServerSettings = Schema.Struct({ @@ -1416,7 +1417,9 @@ export const ServerSettings = Schema.Struct({ /** Lets clients reach this machine's loopback ports over `/api/preview/tunnel`. */ enablePreviewTunnel: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))), cloudSpeechCredentials: CloudSpeechCredentials.pipe( - Schema.withDecodingDefault(Effect.succeed({ openai: "", xai: "", openrouter: "" })), + Schema.withDecodingDefault( + Effect.succeed({ openai: "", xai: "", openrouter: "", deepgram: "" }), + ), ), speechModelId: Schema.String.pipe( Schema.withDecodingDefault(Effect.succeed("handy-computer/parakeet-unified-en-0.6b-gguf")), @@ -1884,6 +1887,7 @@ export const ServerSettingsPatch = Schema.Struct({ openai: Schema.optionalKey(SettingsSecretValue), xai: Schema.optionalKey(SettingsSecretValue), openrouter: Schema.optionalKey(SettingsSecretValue), + deepgram: Schema.optionalKey(SettingsSecretValue), }), ), speechModelId: Schema.optionalKey(Schema.String), diff --git a/packages/contracts/src/speech.ts b/packages/contracts/src/speech.ts index 0784c92be4ab6..a1cd197de5c29 100644 --- a/packages/contracts/src/speech.ts +++ b/packages/contracts/src/speech.ts @@ -8,23 +8,26 @@ export const CloudSpeechApiKey = TrimmedNonEmptyString.check( Schema.isPattern(/^(?![a-z][a-z\d+.-]*:\/\/)[!-~]+$/i), ); -export const CloudSpeechProvider = Schema.Literals(["openai", "xai", "openrouter"]); +export const CloudSpeechProvider = Schema.Literals(["openai", "xai", "openrouter", "deepgram"]); export type CloudSpeechProvider = typeof CloudSpeechProvider.Type; export const CLOUD_SPEECH_LABELS = { openai: "OpenAI", xai: "Grok Voice Transcribe", openrouter: "OpenRouter", + deepgram: "Deepgram", } as const; export const CLOUD_SPEECH_PROVIDER_NAMES = { openai: "OpenAI", xai: "xAI", openrouter: "OpenRouter", + deepgram: "Deepgram", } as const; -/** Servers that predate OpenRouter report only the first two providers. */ +/** Older servers omit providers added after OpenAI and xAI. */ export const CloudSpeechKeys = Schema.Struct({ openai: Schema.Boolean, xai: Schema.Boolean, openrouter: Schema.optionalKey(Schema.Boolean), + deepgram: Schema.optionalKey(Schema.Boolean), }); export type CloudSpeechKeys = typeof CloudSpeechKeys.Type;