Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
feat(desktop): choose the language for on-device voice calls
leepokai25a7f2bf15c7
diff --git a/apps/desktop/native/speech-macos/Sources/main.swift b/apps/desktop/native/speech-macos/Sources/main.swiftindex 5b610d51..3cb1827e 100644--- a/apps/desktop/native/speech-macos/Sources/main.swift+++ b/apps/desktop/native/speech-macos/Sources/main.swift@@ -5,7 +5,7 @@ import Speech// codync-speech: transcribes the microphone on device with SFSpeechRecognizer and prints one// JSON event per line: {"type":"started"}, {"type":"partial"|"final","text":…},// {"type":"level","value":0…1}, {"type":"error","message":…}. It runs until stdin closes or-// SIGTERM. The desktop app (src/main/speech.ts) owns endpointing: it stops this process when+// SIGTERM. `--locales` prints the languages it can transcribe (a JSON array) and exits. The desktop app (src/main/speech.ts) owns endpointing: it stops this process when// the speaker pauses.@MainActor@@ -99,6 +99,11 @@ final class Recognizer {}let arguments = CommandLine.arguments+if arguments.contains("--locales") {+ let ids = SFSpeechRecognizer.supportedLocales().map(\.identifier).sorted()+ FileHandle.standardOutput.write((try? JSONSerialization.data(withJSONObject: ids)) ?? Data("[]".utf8))+ exit(0)+}let locale = arguments.firstIndex(of: "--locale").flatMap { arguments.indices.contains($0 + 1) ? arguments[$0 + 1] : nil }signal(SIGTERM, SIG_IGN)diff --git a/apps/desktop/src/main/speech.ts b/apps/desktop/src/main/speech.tsindex 62e20ac0..ace32d5d 100644--- a/apps/desktop/src/main/speech.ts+++ b/apps/desktop/src/main/speech.ts@@ -1,4 +1,4 @@-import { spawn, type ChildProcessWithoutNullStreams } from 'node:child_process'+import { execFileSync, spawn, type ChildProcessWithoutNullStreams } from 'node:child_process'import { existsSync } from 'node:fs'import { join } from 'node:path'import { app, ipcMain, type WebContents } from 'electron'@@ -58,8 +58,23 @@ function stop() {if (proc && !proc.killed) proc.kill('SIGTERM')}+let supported: string[] | null = null++/** The languages the recognizer can transcribe (identifiers like `zh-TW`), asked once. */+function locales() {+ if (supported) return supported+ const path = helperPath()+ try {+ supported = path ? (JSON.parse(execFileSync(path, ['--locales'], { encoding: 'utf8', timeout: 5000 })) as string[]) : []+ } catch {+ supported = []+ }+ return supported+}+export function registerSpeech() {ipcMain.on('speech:available', (e) => (e.returnValue = process.platform === 'darwin' && helperPath() !== null))+ ipcMain.on('speech:locales', (e) => (e.returnValue = locales()))ipcMain.on('speech:start', (e, locale: string | null) => start(e.sender, locale))ipcMain.on('speech:stop', () => stop())app.on('before-quit', stop)diff --git a/apps/desktop/src/preload/index.ts b/apps/desktop/src/preload/index.tsindex 8b79014a..0dd51f49 100644--- a/apps/desktop/src/preload/index.ts+++ b/apps/desktop/src/preload/index.ts@@ -57,6 +57,7 @@ const bridge: CodyncBridge = {},speech: {available: ipcRenderer.sendSync('speech:available') as boolean,+ locales: () => ipcRenderer.sendSync('speech:locales') as string[],start: (locale) => ipcRenderer.send('speech:start', locale),stop: () => ipcRenderer.send('speech:stop'),onEvent: (cb) => listen('speech:event', cb),diff --git a/apps/desktop/src/renderer/views/call/OnDeviceEngine.ts b/apps/desktop/src/renderer/views/call/OnDeviceEngine.tsindex e3adc2db..b7e5c34c 100644--- a/apps/desktop/src/renderer/views/call/OnDeviceEngine.ts+++ b/apps/desktop/src/renderer/views/call/OnDeviceEngine.ts@@ -117,7 +117,7 @@ export class OnDeviceEngine extends VoiceEngine {if (this.muted || this.ended) returnthis.recognizing = truethis.started = false- window.codync.speech.start(null)+ window.codync.speech.start(VoiceSettings.language() || null)}private stopListening() {diff --git a/apps/desktop/src/renderer/views/call/voice.ts b/apps/desktop/src/renderer/views/call/voice.tsindex 983e7700..6bada123 100644--- a/apps/desktop/src/renderer/views/call/voice.ts+++ b/apps/desktop/src/renderer/views/call/voice.ts@@ -5,6 +5,7 @@ import {chosenVoice,engine,isVoiceProvider,+ language,mode,pause,rate,@@ -44,6 +45,8 @@ export const VoiceSettings = {pause: () => (pause.get() > 0 ? pause.get() : 1.5),/** AVSpeechUtterance's rate (0…1, 0.5 normal), as the Mac stores it. */rate: () => rate.get(),+ /** The on-device recognizer's language; '' is the computer's. */+ language: () => language.get(),}/** This month's realtime minutes, counted on this device. */diff --git a/apps/desktop/src/renderer/views/settings/VoiceChatSettingsView.tsx b/apps/desktop/src/renderer/views/settings/VoiceChatSettingsView.tsxindex 98fe7cba..041d7c1e 100644--- a/apps/desktop/src/renderer/views/settings/VoiceChatSettingsView.tsx+++ b/apps/desktop/src/renderer/views/settings/VoiceChatSettingsView.tsx@@ -1,5 +1,5 @@import { onDeviceUnavailableReason } from '../call/voice'-import { useEffect, useRef, useState } from 'react'+import { useEffect, useMemo, useRef, useState } from 'react'import type { HostClient } from '../../client/host-client'import { Button, CardForm, CardSection, ChoicePicker, IconButton, Spinner, ValueRow } from '../../components/Controls'import { Icon } from '../../components/Icon'@@ -19,6 +19,8 @@ import type { VoiceModels, VoiceProvider } from './voice-settings'export function VoiceChatSettingsView({ showsHeader = true }: { showsHeader?: boolean }) {const [engine, setEngine] = usePref(voice.engine)const [rate, setRate] = usePref(voice.rate)+ const [language, setLanguage] = usePref(voice.language)+ const languages = useMemo(() => voice.languageOptions(window.codync.speech.locales()), [])const provider = voice.isVoiceProvider(engine) ? engine : nullconst [mode, setMode] = usePref(voice.mode(provider ?? 'openai'))const footer = provider@@ -48,6 +50,9 @@ export function VoiceChatSettingsView({ showsHeader = true }: { showsHeader?: bo...(mode === 'speech' ? [<PauseRow key="pause" />] : []),]: [+ <ValueRow key="language" label="Language" detail="The language you speak in calls.">+ <ChoicePicker selection={language} options={languages} onChange={setLanguage} />+ </ValueRow>,<ValueRow key="rate" label="Reading speed"><ChoicePickerselection={rate}diff --git a/apps/desktop/src/renderer/views/settings/voice-settings.ts b/apps/desktop/src/renderer/views/settings/voice-settings.tsindex c96bbf4f..fb7937d6 100644--- a/apps/desktop/src/renderer/views/settings/voice-settings.ts+++ b/apps/desktop/src/renderer/views/settings/voice-settings.ts@@ -61,6 +61,24 @@ export const DEFAULT_RATE = 0.5export const rate = pref('callRate', DEFAULT_RATE)/** Seconds of silence that end what you say. */export const pause = pref('callPause', 1.5)+/** On-device recognition language (a locale identifier); '' follows the system. */+export const language = pref('callLanguage', '')++/** Picker options: the system's language, then every language the recognizer supports, by name. */+export function languageOptions(supported: string[]) {+ const names = new Intl.DisplayNames([navigator.language], { type: 'language' })+ const name = (id: string) => {+ try {+ return names.of(id.replace('_', '-')) ?? id+ } catch {+ return id+ }+ }+ return [+ { id: '', label: 'System' },+ ...supported.map((id) => ({ id, label: name(id) })).sort((a, b) => a.label.localeCompare(b.label)),+ ]+}const cache = new Map<string, Pref<unknown>>()function keyed<T>(key: string, fallback: T): Pref<T> {diff --git a/apps/desktop/src/shared/ipc.ts b/apps/desktop/src/shared/ipc.tsindex 2795dd1c..a2570a91 100644--- a/apps/desktop/src/shared/ipc.ts+++ b/apps/desktop/src/shared/ipc.ts@@ -131,6 +131,9 @@ export interface CodyncBridge {/** On-device speech recognition (macOS: SFSpeechRecognizer in a helper; unavailable on Linux). */speech: {available: boolean+ /** The languages it can transcribe, as locale identifiers. */+ locales(): string[]+ /** `locale` null: the computer's language. */start(locale: string | null): voidstop(): voidonEvent(cb: (e: SpeechEvent) => void): () => voiddiff --git a/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift b/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swiftindex a23c10ae..f48db794 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/OnDeviceEngine.swift@@ -32,7 +32,9 @@ final class OnDeviceEngine: VoiceEngine {}private let send: (String) -> Void- private let recognizer = SFSpeechRecognizer()+ /// The language picked in the call settings, else the phone's.+ private let recognizer = UserDefaults.standard.string(forKey: OnDeviceEngine.languageKey)+ .flatMap { $0.isEmpty ? nil : SFSpeechRecognizer(locale: Locale(identifier: $0)) } ?? SFSpeechRecognizer()private let engine = AVAudioEngine()private var request: SFSpeechAudioBufferRecognitionRequest?private var task: SFSpeechRecognitionTask?@@ -46,6 +48,14 @@ final class OnDeviceEngine: VoiceEngine {/// Call settings (the gear), kept across calls.static let pauseKey = "callPause"static let rateKey = "callRate"+ /// On-device recognition language (a locale identifier); empty follows the system.+ static let languageKey = "callLanguage"++ /// Settings options: the system's language, then every language the recognizer supports, by name.+ static var languageOptions: [(String, String)] {+ let named = SFSpeechRecognizer.supportedLocales().map { ($0.identifier, Locale.current.localizedString(forIdentifier: $0.identifier) ?? $0.identifier) }+ return [("", "System")] + named.sorted { $0.1.localizedStandardCompare($1.1) == .orderedAscending }+ }/// A pause this long ends what you're saying and sends it.private var endOfUtterance: Duration {diff --git a/apps/ios/Kit/Sources/CodyncUI/Call/VoiceChatSettingsView.swift b/apps/ios/Kit/Sources/CodyncUI/Call/VoiceChatSettingsView.swiftindex 6c987d6e..d81f2ca7 100644--- a/apps/ios/Kit/Sources/CodyncUI/Call/VoiceChatSettingsView.swift+++ b/apps/ios/Kit/Sources/CodyncUI/Call/VoiceChatSettingsView.swift@@ -8,6 +8,8 @@ import SwiftUIpublic struct VoiceChatSettingsView: View {@AppStorage(VoiceSettings.engineKey) private var engine = "device"@AppStorage(OnDeviceEngine.rateKey) private var rate = Double(AVSpeechUtteranceDefaultSpeechRate)+ @AppStorage(OnDeviceEngine.languageKey) private var language = ""+ @State private var languages = OnDeviceEngine.languageOptions@Environment(\.accessibilityReduceMotion) private var reduceMotionpublic init() {}@@ -24,6 +26,9 @@ public struct VoiceChatSettingsView: View {if let provider = VoiceProvider(rawValue: engine) {ModeRows(provider: provider).id(provider)} else {+ ValueRow("Language", detail: "The language you speak in calls.") {+ ChoicePicker(selection: $language, options: languages)+ }ValueRow("Reading speed") {ChoicePicker(selection: $rate, options: [(0.42, "Slower"), (Double(AVSpeechUtteranceDefaultSpeechRate), "Normal"), (0.56, "Faster"),diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.mdindex ae620817..763379ed 100644--- a/apps/ios/WhatsNew.md+++ b/apps/ios/WhatsNew.md@@ -15,6 +15,7 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- 進聊天室先顯示最新的訊息,往上捲再接上更早的;更新 app 之後也不用等對話重新載入。- 回覆裡的表格、分隔線、巢狀清單和行內程式碼都會正確排版。- 開啟 app 時會有 bot 動畫陪你等連線,畫面出現時新訊息已經同步好了。+- 裝置上的語音通話可以選擇你說的語言(語音聊天設定 → 語言),不再只跟著系統的第一語言。### en-US@@ -24,3 +25,4 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o- A chat opens on its newest messages and brings in earlier ones as you scroll up, and no longer reloads after an app update.- Tables, dividers, nested lists and inline code in replies are now formatted properly.- Opening the app now shows an animated bot while it connects, so new messages are already in when the list appears.+- On-device voice calls let you choose the language you speak (Voice chat settings → Language) instead of always following the system's first language.diff --git a/docs/features/voice-call.md b/docs/features/voice-call.mdindex 71fecd34..8bc05e9a 100644--- a/docs/features/voice-call.md+++ b/docs/features/voice-call.md@@ -15,7 +15,9 @@ The bot is the same agent on the computer; the call only changes how you talk to- Desktop: the capsule sits 16 CSS pixels below the window top and explicitly excludes itselffrom Electron's window-drag region so the gear, mute and end buttons receive mouse clicks.The iPhone places its capsule below native navigation; the terminal has no call controls.-- Speech → text with `SFSpeechRecognizer` (on-device when the language supports it). A pause ends an+- Speech → text with `SFSpeechRecognizer` (on-device when the language supports it) in the language+ picked under Voice chat → Language (`callLanguage`; empty follows the system's first language,+ which is often English on bilingual setups). A pause ends anutterance and sends it as an ordinary message (`BotStore.send`), so it takes the normal path:queued while the bot works, folded into its next turn. What you said appears in the chat as yourmessage; the bot's reply appears as its message.