Voice-first AI desktop companion for macOS. Pure Swift app with a single WebSocket to Deepgram's Voice Agent API for server-side STT + LLM + TTS orchestration. BYO LLM via OpenRouter, client-side tool execution, and a dev console UI.
Core loop: Press hotkey -> speak naturally -> Deepgram transcribes -> LLM reasons (via OpenRouter) -> Deepgram speaks back -> tools execute locally on your Mac
Mental model: One WebSocket handles everything. No Python backend. No local LLM. The Deepgram Voice Agent API orchestrates speech-to-text, LLM inference, and text-to-speech server-side. Your Mac just sends audio and runs tool calls.
macOS App (SwiftUI/AppKit, floating companion orb + dev console)
|
| Single WebSocket (wss://agent.deepgram.com/v1/agent/converse)
| - Binary frames: PCM16 24kHz mono audio (both directions)
| - Text frames: JSON control messages (Voice Agent protocol)
|
v
Deepgram Voice Agent API (server-side orchestration)
|-- STT: Deepgram Nova-3
|-- LLM: BYO via OpenRouter (google/gemini-3.1-flash-lite-preview)
|-- TTS: Deepgram Aura-2 (aura-2-vesta-en)
|-- Function calling: client-side (FunctionCallRequest/Response)
App: Swift 5.9 . SwiftUI . AppKit . AVAudioEngine . CoreAudio/AudioUnit . URLSessionWebSocketTask
Voice Pipeline: Deepgram Voice Agent API (Nova-3 STT + Aura-2 TTS) . OpenRouter (BYO LLM)
Tools: Client-side execution via function calling -- bash, files, AppleScript, screen capture, web search, deep reasoning
Infrastructure: macOS Keychain + file fallback (API keys) . KeyboardShortcuts (SPM)
Voice Conversation
- Full-duplex voice loop: speak naturally, hear responses
- Barge-in support (interrupt agent while speaking)
- Conversation history preserved across reconnects within a session
- Voice-optimized output (no markdown artifacts in speech)
- Latency metrics (total, TTS, LLM) logged per turn
- 10s keepalive to maintain WebSocket connection
- Two audio route modes:
Clear OutputandAirPods Mic
Client-Side Tools (8 total)
| Tool | Purpose | Approval Required |
|---|---|---|
safe_bash |
Shell commands via allowlist + metachar rejection | If confirmDestructive |
applescript |
macOS automation via osascript | If confirmDestructive |
file_read |
Read files (1MB limit, home dir sandboxed) | No |
file_write |
Write files (auto-creates parent dirs) | If confirmDestructive |
frontmost_app_context |
Active app info via Accessibility API | No |
capture_display |
Screen capture + OpenAI vision analysis | No |
reason_deeply |
Delegation to gpt-5-mini for complex reasoning | No |
web_search |
Web search via OpenAI Responses API | No |
Companion Orb (floating always-on-top panel)
- Animated presence rings show idle/listening/thinking/speaking states
- Liquid glass orb core on macOS 26+ (Tahoe)
- Click orb to start/stop voice session
- Hover to reveal control buttons (talk, stop, settings) with 400ms delay
- Transcript text displays below orb, auto-dismisses 7s after playback stops
- Hover orb to show last assistant reply even after dismiss
- White cloud glow on hover when idle (PresenceView core without rings)
- Always-on-top (.statusBar level), click-through when unfocused, visible on all spaces
Dev Console (main window)
- Real-time log with level filtering (info, warning, error, debug)
- Live transcript display (user + assistant turns)
- Tool approval UI with "always approve" option
- Connection state indicator
- Audio capture/playback status
Settings
- API key management (Deepgram, OpenRouter, OpenAI) stored in Keychain
- Voice selection (12 Aura-2 + 3 legacy Aura-1 voices)
- Audio route mode selection for Bluetooth headsets
- LLM model selection (any OpenRouter model)
- Global hotkey configuration
- Safe mode and destructive action confirmation toggles
DeepVoice ships with two audio route modes:
Clear Output: uses a built-in or other non-Bluetooth mic for capture and keeps Bluetooth headphones focused on playback quality.AirPods Mic: uses macOSVoiceProcessingIOfor headset capture so AirPods-style conversation works more naturally. This mode still uses the Bluetooth headset path, so audio may sound like call audio rather than music-quality playback.
Use Clear Output if you care most about assistant voice quality. Use AirPods Mic if you care most about natural full-duplex conversation on a Bluetooth headset.
DeepVoice/
Package.swift # Swift 5.9+, macOS 14+
Sources/DeepVoice/
# Core Voice Agent
DeepgramAgentClient.swift # WebSocket client to Voice Agent API
VoiceAgentSettings.swift # Settings payload builder (STT/LLM/TTS config)
FunctionCallHandler.swift # Bridges FunctionCallRequest to ToolRegistry
# App
DeepVoiceApp.swift # @main app, AppDelegate, delegate wiring
DevConsoleState.swift # Shared state: app state, log entries, approvals, transcript
DevConsoleView.swift # Dev console UI (main window)
SettingsView.swift # API keys, voice, model settings
TranscriptOverlay.swift # Live transcript display + TranscriptEntry merge logic
# Companion (floating orb)
CompanionView.swift # Floating orb UI: hover controls, click-to-talk, text display
CompanionPanel.swift # NSPanel wrapper: always-on-top, click-through, positioning
PresenceView.swift # Canvas-based animated rings with showRings parameter
# Tools
ToolRegistry.swift # Tool registration, schemas, dispatch
ShellTools.swift # safe_bash + applescript
FileTools.swift # file_read + file_write
DesktopTools.swift # frontmost_app_context + capture_display
AITools.swift # reason_deeply + web_search
# Shared
Types.swift # AppState, ToolCall, JSONValue, condenseForVoice
OpenAIClient.swift # Shared OpenAI API caller and model constants
# Audio
AudioManager.swift # Dual audio modes: HAL capture for clear output, VoiceProcessingIO for headset mic mode
# Infrastructure
Config.swift # DeepVoiceConfig (providers, model, voice, audio route mode)
KeychainHelper.swift # Keychain + file fallback for API keys
HotkeyManager.swift # Option+S toggle, Option+Shift+S settings
Prompts.swift # System prompt + delegation prompt
DesktopContextToolExecutor.swift # macOS native context tools
docs/
architecture.md # Architecture comparison and migration notes
provider-comparison.md # STT/LLM/TTS provider analysis
spec.md # Original specification
findings.md # Research findings
swift build
swift run # macOS only, needs mic + screen permissionsRequires macOS 14+ with Xcode command line tools.
Set via Settings UI (Option+Shift+S). Stored in macOS Keychain with file-based fallback (~/.deepvoice/keys.json) for unsigned builds:
| Key | Purpose |
|---|---|
| Deepgram | Voice Agent API (STT + TTS orchestration) |
| OpenRouter | BYO LLM (gemini-3.1-flash-lite-preview by default) |
| OpenAI | reason_deeply delegation, web_search, capture_display vision |
~/.deepvoice/
config.json # DeepVoiceConfig (providers, model, voice, audio route mode, flags)
keys.json # File-based API key fallback (chmod 600, gitignored)
profile.md # User profile
preferences.md # User preferences
daily/ # Daily context directory
Keychain: com.thebrownproject.deepvoice service.
- Single WebSocket to Deepgram Voice Agent -- server handles STT+LLM+TTS orchestration, client just sends/receives audio and handles function calls
- BYO LLM via OpenRouter --
provider.type = "open_ai"with customendpointpointing at OpenRouter's OpenAI-compatible API. Use any model. - Client-side function calling -- all tools run locally on the Mac, results sent back through the WebSocket
- Shell metacharacter blocking -- safe_bash rejects
;|&\$(){}\!<>\n\r` before allowlist check to prevent injection - Tool name aliasing -- LLMs call "bash" instead of "safe_bash". Fixed with prompt instructions, Deepgram alias registration, and client-side FunctionCallHandler mapping.
- No Python backend -- eliminates the local server, IPC protocol, and process management. One process, one WebSocket.
- Dual-window UI -- CompanionPanel (floating orb at .statusBar level) for always-visible voice control, DevConsoleView (main window) for development/debugging. Both share the same DevConsoleState and DevConsoleActions.
- Two audio route modes --
Clear Outputuses HAL capture on a non-Bluetooth mic to preserve playback quality.AirPods MicusesVoiceProcessingIOat 44.1kHz for headset capture, then converts to the 24kHz PCM16 wire format Deepgram expects. - Conversation history across reconnects -- On WebSocket reconnect, transcript history is injected into the system prompt via
UpdatePromptso the agent has context from the current session. - ConfigStore as single source of truth --
@ObservableConfigStore shared via SwiftUI.environment(). Settings UI binds directly. Config changes propagate live to ToolRegistry viawithObservationTracking.
DeepVoice started as a spike inside the Samantha project to evaluate replacing the Python backend (OpenAI Agents SDK + local WebSocket IPC) with a pure Swift approach using Deepgram's Voice Agent API. The spike proved the architecture works: same voice quality, simpler stack, 10-50x cheaper than OpenAI Realtime.