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
fix(desktop): keep the on-device speech helper running through a voice call
leepokai09d10a873fe5
diff --git a/apps/desktop/native/speech-macos/Sources/main.swift b/apps/desktop/native/speech-macos/Sources/main.swiftindex 260e5e72..70ce32a0 100644--- a/apps/desktop/native/speech-macos/Sources/main.swift+++ b/apps/desktop/native/speech-macos/Sources/main.swift@@ -24,8 +24,7 @@ final class Recognizer {guard await AVCaptureDevice.requestAccess(for: .audio) else {return fail("Allow the microphone for Codync in System Settings to talk to your bots.")}- let status = await withCheckedContinuation { done in SFSpeechRecognizer.requestAuthorization { done.resume(returning: $0) } }- guard status == .authorized else {+ guard await Self.speechAuthorized() else {return fail("Allow Speech Recognition for Codync in System Settings to talk to your bots.")}guard let recognizer, recognizer.isAvailable else {@@ -41,27 +40,16 @@ final class Recognizer {guard format.sampleRate > 0, format.channelCount > 0 else {return fail("Couldn't start the microphone: no microphone is available right now.")}- input.installTap(onBus: 0, bufferSize: 1024, format: format) { buffer, _ in- request.append(buffer)- let level = Self.level(buffer)+ input.installTap(onBus: 0, bufferSize: 1024, format: format, block: Self.tap(request) { level inTask { @MainActor in self.report(level) }- }+ })do {engine.prepare()try engine.start()} catch {return fail("Couldn't start the microphone: \(error.localizedDescription)")}- task = recognizer.recognitionTask(with: request) { result, error in- let text = result?.bestTranscription.formattedString- let final = result?.isFinal ?? false- let message = error?.localizedDescription- Task { @MainActor in- if let text { emit(["type": final ? "final" : "partial", "text": text]) }- // An error after the stream was ended on purpose is just the end.- if let message, !final, self.request != nil { emit(["type": "error", "message": message]) }- }- }+ task = recognizer.recognitionTask(with: request, resultHandler: Self.results(self))emit(["type": "started"])}@@ -84,6 +72,36 @@ final class Recognizer {exit(1)}+ // MARK: callbacks the frameworks run off the main thread (built outside the main actor, which+ // would otherwise trap on them)++ nonisolated private static func speechAuthorized() async -> Bool {+ await withCheckedContinuation { done in+ SFSpeechRecognizer.requestAuthorization { done.resume(returning: $0 == .authorized) }+ }+ }++ nonisolated private static func tap(_ request: SFSpeechAudioBufferRecognitionRequest,+ meter: @escaping @Sendable (Float) -> Void) -> AVAudioNodeTapBlock {+ { buffer, _ in+ request.append(buffer)+ meter(level(buffer))+ }+ }++ nonisolated private static func results(_ owner: Recognizer) -> @Sendable (SFSpeechRecognitionResult?, (any Error)?) -> Void {+ { result, error in+ let text = result?.bestTranscription.formattedString+ let final = result?.isFinal ?? false+ let message = error?.localizedDescription+ Task { @MainActor in+ if let text { emit(["type": final ? "final" : "partial", "text": text]) }+ // An error after the stream was ended on purpose is just the end.+ if let message, !final, owner.request != nil { emit(["type": "error", "message": message]) }+ }+ }+ }+nonisolated private static func level(_ buffer: AVAudioPCMBuffer) -> Float {guard let data = buffer.floatChannelData?[0] else { return 0 }let count = Int(buffer.frameLength)@@ -129,4 +147,6 @@ FileHandle.standardInput.readabilityHandler = { handle in}Task { @MainActor in await recognizer.start() }-dispatchMain()+// Not dispatchMain(): it ends the main thread and drains the main queue on worker threads, where the+// MainActor checks in the handlers above trap.+RunLoop.main.run()