voice-mcp
by Exawyll
README.md
# voice-mcp
**Local-first macOS voice daemon & MCP server** to talk directly to your coding agents (**Claude Code**, **Antigravity**, or any stdio MCP client) — an open-source, privacy-aware alternative to **Wispr Flow** with **real-time barge-in**.
---
## Why `voice-mcp`?
Instead of dictating text and reading walls of markdown back, `voice-mcp` combines:
1. **System-wide `Fn` keyboard daemon (`voice-daemon`)** with a native macOS menu bar icon (`🎙️` / `🔊` / `🔴`):
- **Hold `Fn`** (≥ 200 ms, pre-capture at `t=0` + 250 ms tail): **Open Space silent dictation** — streams speech to Gradium STT and pastes cleanly at your cursor anywhere on macOS without pressing Enter.
- **Double-tap `Fn`** (< 400 ms): **Direct Voice Interaction mode** — listens hands-free with semantic turn detection, pastes `[mode vocal] <transcript>` and presses Enter so your agent summarizes in chat + replies aloud with **Noémie** and **instant barge-in**.
2. **Stdio MCP Server (`voice-mcp`)** exposing `ecouter`, `parler`, `dialoguer`, and `statut_voix`, synchronized with the shared `oral` / `ecrit` mode (`~/.cache/voice-mcp/mode.json`).
---
## Architecture
```
Microphone (24 kHz PCM, in-memory only)
│
├─► Gradium STT WebSocket (eu.api.gradium.ai)
│ • Semantic VAD (2.0 s horizon) & keyword boosting (keywords.yaml)
│ • Barge-in RMS detector cuts TTS in < 80 ms with 480 ms pre-roll
│
├─► Coding Agent (Claude Code / Antigravity via MCP stdio)
│ • Keeps all workspace tools, skills & safety guardrails
│ • Outputs 3–5 bullet summary in chat + 2 short spoken sentences
│
└─► Gradium Phonon TTS (100% local via ptts, 0 API credits)
• Default voice: Noémie (15 FR voices cached on demand)
• Hot-plug audio device refresh (headset / speakers)
```
---
## Installation
Prerequisites: macOS (Apple Silicon / Intel), Python 3.11–3.13, [`uv`](https://docs.astral.sh/uv/).
```bash
git clone https://github.com/Exawyll/voice-mcp.git
cd voice-mcp
uv sync --python 3.12
```
### 1. Configure API Key & Local Settings
```bash
cp .env.example .env
```
Edit `.env` and set your Gradium API key (free tier available at [gradium.ai](https://gradium.ai), routed to EU endpoint `eu.api.gradium.ai` by default):
```env
GRADIUM_API_KEY=your_gradium_api_key
```
*(Optional)* Copy `keywords.local.yaml.example` to `keywords.local.yaml` (gitignored) to boost your own domain acronyms and project terms.
---
## Quick Test (CLI)
```bash
# Check config (key redacted) and audio devices
uv run voice-test status
# List available French Phonon voices
uv run voice-test voices
# Test local TTS (0 credits)
uv run voice-test tts "Bonjour, je suis Noémie." --voice Noémie
# Test streaming STT
uv run voice-test stt --timeout 20
# Test real-time barge-in (interrupt while speaking)
uv run voice-test bargein
```
---
## Connect to Coding Agents (MCP)
### Claude Code
```bash
claude mcp add --scope user voice-mcp -- \
uv --directory /path/to/voice-mcp run voice-mcp
```
### Antigravity (`~/.gemini/config/mcp_config.json`)
```json
{
"mcpServers": {
"voice-mcp": {
"command": "/path/to/uv",
"args": [
"--directory",
"/path/to/voice-mcp",
"run",
"voice-mcp"
]
}
}
}
```
### Global Agent Rule (`~/.claude/CLAUDE.md` / `~/.gemini/GEMINI.md`)
```markdown
- If a message starts with `[mode vocal]`, show a short 3–5 bullet summary in chat and reply aloud via `dialoguer()` in 2 short sentences max.
- Without `[mode vocal]` (or when Open Space silent mode is active), reply in text only.
```
---
## macOS Keyboard Daemon & Auto-Start (`LaunchAgent`)
### One-time macOS Permissions
1. **System Settings > Keyboard**: *Press 🌐 key to* → **Do Nothing**.
2. **Privacy & Security > Input Monitoring**: allow your Terminal / Python binary.
3. **Privacy & Security > Accessibility**: allow your Terminal / Python binary (for `Cmd+V` / `Return` paste).
### Run Manually or Install at Login
```bash
# Verify macOS permissions
uv run voice-daemon --check-permissions
# Run interactively with menu bar icon
uv run voice-daemon
# Install and start automatically at macOS login
# (packages ~/Applications/VoiceMCP.app so Microphone & Accessibility permissions stick cleanly)
uv run voice-daemon --install-launchagent
# Stop and remove LaunchAgent
uv run voice-daemon --uninstall-launchagent
```
Logs when running via `LaunchAgent`: `~/Library/Logs/voice-mcp-daemon.log`.
Note: `--install-launchagent` creates `~/Applications/VoiceMCP.app` on macOS so **Microphone** and **Accessibility** permissions apply cleanly to `VoiceMCP` instead of a generic Python binary.
---
## Privacy, Security & Licensing
- **No audio stored on disk**: microphone audio stays in memory and is streamed only to the configured Gradium region (`eu` by default).
- **Local TTS output**: Phonon runs 100% locally on-device, so agent replies never leave your machine.
- **Secrets safety**: `.env` and `keywords.local.yaml` are gitignored; `GRADIUM_API_KEY` is never exposed in `statut_voix()` or error messages; native macOS truststore (`truststore`) handles corporate TLS proxies without disabling certificate verification.
- **Licensing**:
- `voice-mcp` source code: **MIT** ([LICENSE](LICENSE)).
- Underlying Phonon weights: `phonon-31m-en` is **Apache 2.0**; `phonon-40m-fr` (used for French voices such as Noémie) is **CC BY-NC 4.0** (non-commercial — commercial license available from Gradium, or switch `VOICE_TTS_BACKEND=say` / `gradium`).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues