Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(dictation): say when Windows has no recognizer for the language
AdityaUmale124dba3249ab
diff --git a/electron/resources/speech-helper-windows.ps1 b/electron/resources/speech-helper-windows.ps1index b10572a5cf..92c8203956 100644--- a/electron/resources/speech-helper-windows.ps1+++ b/electron/resources/speech-helper-windows.ps1@@ -24,11 +24,18 @@ function Join-Text($left, $right) {try {Add-Type -AssemblyName System.Speech- $installed = @([System.Speech.Recognition.SpeechRecognitionEngine]::InstalledRecognizers())} catch {Send-Line @{ error = 'speech-unavailable' }exit 1}+# Throws (NullReferenceException) instead of returning an empty list when no desktop recognizer is registered, as+# for languages Windows only covers with its newer speech packs (Portuguese (Brazil)).+try {+ $installed = @([System.Speech.Recognition.SpeechRecognitionEngine]::InstalledRecognizers())+} catch {+ Send-Line @{ error = 'speech-language-missing' }+ exit 1+}if ($installed.Count -eq 0) {Send-Line @{ error = 'speech-language-missing' }exit 1diff --git a/src/components/CallView.tsx b/src/components/CallView.tsxindex b8835e1d52..224f347ff7 100644--- a/src/components/CallView.tsx+++ b/src/components/CallView.tsx@@ -679,7 +679,9 @@ function Call({ bot }: { bot: Bot }) {? "composer.dictation.disabled": reason === "speech-not-authorized"? "call.turns.speechNotAuthorized"- : "composer.dictation.failed"),+ : reason === "speech-language-missing"+ ? "composer.dictation.languageMissing"+ : "composer.dictation.failed"),);return;}diff --git a/src/components/Composer.dictation.test.ts b/src/components/Composer.dictation.test.tsindex de7cc01bd4..16654c3422 100644--- a/src/components/Composer.dictation.test.ts+++ b/src/components/Composer.dictation.test.ts@@ -184,6 +184,17 @@ describe("native dictation in the real composer", () => {await expect.poll(() => input().value).toBe("元スレッドの文章。");});+ it("says Windows has no recognizer for the language instead of asking to try again", () => {+ flushSync(() => end({ code: 1, reason: "speech-language-missing" }));+ expect(container.textContent).toContain(t("composer.dictation.languageMissing"));+ expect(container.textContent).not.toContain(t("composer.dictation.failed"));+ });++ it("still asks to try again for other helper failures", () => {+ flushSync(() => end({ code: 1, reason: "helper-start-failed" }));+ expect(container.textContent).toContain(t("composer.dictation.failed"));+ });+it("retains text when recognition ends in an error", () => {hear("失敗しても残す文章。");flushSync(() => end({ code: 1, reason: "recognition-error" }));diff --git a/src/components/GroupCallView.tsx b/src/components/GroupCallView.tsxindex b8914c6668..8e3dca05a1 100644--- a/src/components/GroupCallView.tsx+++ b/src/components/GroupCallView.tsx@@ -327,7 +327,9 @@ function GroupCall({ group, members }: { group: Group; members: Bot[] }) {? "composer.dictation.disabled": reason === "speech-not-authorized"? "call.turns.speechNotAuthorized"- : "composer.dictation.failed"),+ : reason === "speech-language-missing"+ ? "composer.dictation.languageMissing"+ : "composer.dictation.failed"),);return;}diff --git a/src/lib/use-composer-dictation.ts b/src/lib/use-composer-dictation.tsindex 770e30a1d7..8ddd744f4a 100644--- a/src/lib/use-composer-dictation.ts+++ b/src/lib/use-composer-dictation.ts@@ -67,7 +67,8 @@ export function useComposerDictation({ draftId, text, onText }: {} else if (code === 1) {// A refused permission comes with a way to the pane that grants it.setSpeechError(message ?? (reason === "speech-not-authorized" ? withOpenSettings(t("composer.dictation.permission"), "speech")- : t(reason === "dictation-disabled" ? "composer.dictation.disabled" : "composer.dictation.failed")));+ : t(reason === "dictation-disabled" ? "composer.dictation.disabled"+ : reason === "speech-language-missing" ? "composer.dictation.languageMissing" : "composer.dictation.failed")));}});void bridge.speechStart().catch(() => {diff --git a/src/locales/de.json b/src/locales/de.jsonindex dd41053422..c30795bbab 100644--- a/src/locales/de.json+++ b/src/locales/de.json@@ -1160,6 +1160,7 @@"composer.error.noImages": "Der gewählte Beantworter unterstützt keine Bildanhänge.","composer.error.clipboardImage": "Das Bild aus der Zwischenablage ließ sich nicht lesen. Häng stattdessen die Bilddatei an.","composer.dictation.macOnly": "Diktieren gibt es vorerst nur unter macOS.",+ "composer.dictation.languageMissing": "Windows hat für deine Sprache keine Spracherkennung, die das Diktieren nutzen kann. Um hier zu diktieren, füge in Einstellungen → KI → Weitere Dienste einen Fish-Audio- oder ElevenLabs-Schlüssel hinzu oder nutze die Spracheingabe von Windows (Windows-Taste + H).","composer.dictation.unavailable": "Diktieren ist in diesem Build nicht verfügbar.","composer.dictation.start": "Diktieren starten","composer.dictation.stop": "Diktieren stoppen",diff --git a/src/locales/en.json b/src/locales/en.jsonindex 0efb4ccdd6..80d1d554bd 100644--- a/src/locales/en.json+++ b/src/locales/en.json@@ -3073,6 +3073,7 @@"composer.dictation.permission": "Dictation needs Microphone and Speech Recognition access. Turn both on in System Settings → Privacy & Security.","composer.dictation.disabled": "Turn on Dictation in System Settings → Keyboard, then try again.","composer.dictation.failed": "Dictation couldn't start. Try again.",+ "composer.dictation.languageMissing": "Windows has no speech recognizer for your language that dictation can use. To dictate here, add a Fish Audio or ElevenLabs key in Settings → AI → Other services, or use Windows voice typing (Windows key + H).","composer.dictation.unavailable": "Dictation isn't available in this build.","composer.dictation.start": "Start dictation","composer.dictation.stop": "Stop dictation",diff --git a/src/locales/pt-br.json b/src/locales/pt-br.jsonindex 213b6cf5a9..4fa10b5f0e 100644--- a/src/locales/pt-br.json+++ b/src/locales/pt-br.json@@ -2861,6 +2861,7 @@"composer.dictation.permission": "O ditado precisa de acesso ao Microfone e ao Reconhecimento de Fala. Ative os dois em Ajustes do Sistema → Privacidade e Segurança.","composer.dictation.disabled": "Ligue o Ditado em Ajustes do Sistema → Teclado e tente novamente.","composer.dictation.failed": "Não foi possível iniciar o ditado. Tente novamente.",+ "composer.dictation.languageMissing": "O Windows não tem um reconhecedor de fala para o seu idioma que o ditado possa usar. Para ditar aqui, adicione uma chave do Fish Audio ou do ElevenLabs em Configurações → IA → Outros serviços, ou use a digitação por voz do Windows (tecla Windows + H).","composer.dictation.unavailable": "O ditado não está disponível nesta versão.","composer.dictation.start": "Iniciar o ditado","composer.dictation.stop": "Parar o ditado",