Dictating long prompts and listening to model responses without leaving your workflow is much faster when voice input and text-to-speech live directly inside OpenCode. opencode-voice-dictation (V2) adds voice dictation and read-aloud support to both OpenCode Desktop (gui-experimental) and the OpenCode TUI across Windows and Linux.
This guide covers how the plugin works under the hood, how to install and configure it, and how to set up WhisperX (via WSL2 + NVIDIA GPU), whisper.cpp (Linux), and Windows environments.
Quick Installation & Updates
Install the plugin from npm or directly from GitHub (the dist/ bundle is committed in the repository):
opencode plugin add opencode-voice-dictation
# Or directly from the repository:
# opencode plugin add github:evious/opencode-voice-dictation
To update later:
`opencode plugin update opencode-voice-dictation`
Restart OpenCode Desktop or the TUI after installing. The plugin registers in the global opencode.json of the environment where you run the command.
Manual / Development Build
If you are building from source or testing changes locally:
`npm install
npm run typecheck
npm run build
npm test`
npm run build outputs dist/gui-experimental.cjs.
npm run dev rebuilds on changes so OpenCode Desktop can reload the plugin.
For manual Desktop setup on Windows, copy package.json, dist/gui-experimental.cjs, and src/index.ts into a folder (such as C:\Users\<user>\opencode-plugins\voice-dictation) and reference it in the global opencode.json (C:\Users\<user>\.config\opencode\opencode.json). If you build inside WSL, copy the folder to a Windows path rather than pointing Desktop to a Linux path.
Architecture: How Dictation & Playback Work
The plugin splits responsibilities across the Desktop renderer (Solid), the Electron main process, the server/RPC layer (src/index.ts, src/rpc.ts), and the TUI (./tui).
`[Desktop Window (Solid)]
├─ ComposerPill (🎤 Dictate / Read) ──▶ ctx.main(Dictation).start ──▶ Electron main IPC
│ ▲ │
│ └──── "final" event ──▶ composer.insert(text) ▼
│ powershell.exe -File dictation-<hash>.ps1
└─ getUserMedia + MediaRecorder ──▶ RPC ──▶ Server (src/whisper / src/whispercpp / src/edge.ts)`
Key design details across platforms:
Windows Voice Typing (Win+H): The default dictation path on Windows. The pill focuses the composer, the main process sends Win+H via keybd_event, and Windows types directly into the focused input without the plugin modifying text.
Offline System.Speech (Windows): Runs via a PowerShell script (dictation-<hash>.ps1) in %TEMP%\opencode-voice-dictation, emitting one JSON line per recognized phrase. Does not require internet, though it lacks automatic punctuation/capitalization and has lower accuracy than Whisper or Windows 11 dictation.
WhisperX (Windows + WSL2 + NVIDIA GPU): Audio is written to %TEMP%\opencode-voice-dictation, passed to WSL, and processed by a persistent Python worker (src/whisper/worker.py) using CUDA/GPU. Audio stays on your machine.
whisper.cpp (Linux): The renderer records with getUserMedia + MediaRecorder and sends audio over RPC to the server (src/whispercpp/server.ts), which converts it with ffmpeg (16 kHz WAV) and queries a local whisper-server keeping the model in memory. On first use on Linux, it can download the binary (~10 MB) and model (base-q5_1, 57 MB, or small-q5_1, 180 MB) into ~/.local/share/opencode-voice-dictation.
Text-to-Speech (Read Aloud): Cleans Markdown (src/speech-text.ts)—stripping code fences, backticks, bolding, headings, and bullet markers while keeping link text—splits text into sentences, and speaks using Edge neural voices online (with automatic fallback to system/SAPI voices).
Setting Up WhisperX (WSL + NVIDIA GPU)
For higher-accuracy local transcription when you have an NVIDIA GPU and WSL2 ready:
Ensure WSL2, Python, CUDA, and a NVIDIA GPU are configured on your machine.
Authenticate with Hugging Face (huggingface-cli login) and accept the terms for the pyannote VAD model if prompted by WhisperX.
Open Settings → Voice Dictation in OpenCode Desktop and select WhisperX local (WSL) as the dictation engine.
Configure:
Python environment path: Path to the Python executable inside your WhisperX venv.
WhisperX model: Defaults to large-v3-turbo (or large-v3 / medium as needed).
Language: Automatic detection, or explicit es, en, pt.
Click Check WhisperX to start the worker and verify GPU and model availability.
Note: Expect the first WhisperX dictation to take ~10–30 seconds while loading the model onto the GPU; subsequent dictations are much faster.
Windows-Specific Notes
Speech recognition language pack: For System.Speech, install the speech recognition pack under Settings → Time & language → Language & region → (Language) → Options → Speech recognition (a display pack alone is not enough). You can verify installed recognizers in PowerShell:
Add-Type -AssemblyName System.Speech
[System.Speech.Recognition.SpeechRecognitionEngine]::InstalledRecognizers() |
ForEach-Object { $_.Culture.Name }
Microphone & permissions: Confirm your default input device in Settings → System → Sound → Input. Because the plugin spawns PowerShell scripts in %TEMP%\opencode-voice-dictation and sends Win+H via keybd_event, Windows or security tools like Kaspersky may prompt for permission on first run or block synthetic keystrokes—if Win+H is blocked, switch to System.Speech or WhisperX.Session safety: If you switch sessions while dictating, text is discarded with a warning so it is not inserted into the wrong session. Starting dictation in another window stops any active dictation elsewhere.Using the TUI (./tui)The TUI provides commands, shortcuts, and a clickable row above the composer (🎤 Dictar │ 🔊 Leer │ ⏸ Pausar):CommandShortcutBehavior/dictado<leader>d (Ctrl+X, then d)Windows: opens Win+H. Linux: records and transcribes with whisper.cpp./leer<leader>v (Ctrl+X, then v)Reads the last response aloud; stops if already reading./pausar (or /pausa)<leader>p (Ctrl+X, then p)Pauses or resumes playback (works with Edge; SAPI fallback has no real pause)./ajustes-voz—Opens TUI voice settings (model, language, insertion mode, voice, rate, etc.).
Linux TUI Dependencies & WSL
On Linux, ensure the OpenCode server runs on Linux so whisper.cpp is available, and install system tools:
sudo apt install -y ffmpeg xdotool xclip
Optional fallback TTS engines:
sudo apt install -y speech-dispatcher espeak-ng
Use xdotool + xclip on X11, or wtype + wl-clipboard on Wayland.
Under WSL, audio capture/playback works via WSLg/PulseAudio, while prompt insertion uses the Windows clipboard + SendKeys rather than xdotool.
TUI Configuration (opencode.jsonc & cli.json)
Configure initial TUI voice options in opencode.jsonc:
{
"plugins": [
{
"package": "opencode-voice-dictation",
"options": {
"model": "base-q5_1",
"language": "auto",
"maxSeconds": 60,
"insert": "auto",
"engine": "edge"
}
}
]
}
insert options: auto (appendPrompt → xdotool/clipboard), type, clipboard, or append.
engine options: edge or system.
Changes made in /ajustes-voz persist in the TUI's durable store (opencode.jsonc seeds initial values; Reset reapplies opencode.jsonc).
To prevent the TUI from compacting long dictations into [Pasted ~N lines], add the following to ~/.config/opencode/cli.json on Linux (or C:\Users\<user>\.config\opencode\cli.json on Windows), which reloads live:
`{
"prompt": {
"paste": "full"
}
}`
Troubleshooting & Limitations
No speech recognizer / language pack found: Install the Windows speech recognition language pack (not just the display pack) or lower System.Speech minimum confidence (e.g., 0.2) and check mic input levels.
WhisperX stuck on "Transcribing…": Check the toast/logs for Python path, CUDA, or Hugging Face token/VAD model access issues.
whisper.cpp reports not installed or fails to start: Download the engine from settings, verify ffmpeg -version is in PATH, and check glibc compatibility (tested on Ubuntu 22.04+ / 24.04).
RPC 400 / Edge voices not loading: Reload the plugin under Settings → Extensions → Plugins → Reload or restart the service.
Experimental API & Cloud Roadmap: The Desktop GUI plugin API (gui-experimental) is experimental and may shift across OpenCode versions. Cloud providers (Google Cloud Speech-to-Text, OpenAI gpt-4o-transcribe / whisper-1, Deepgram, AssemblyAI) are listed on the roadmap—when adding new engines (src/rpc.ts, src/index.ts, src/gui/settings.tsx, src/gui/window.tsx), keep API keys on the server/store or environment variables rather than exposing them to the renderer.
Have you tried opencode-voice-dictation on Windows, Linux, or WSL? Share your setup, WhisperX/whisper.cpp model choices, or any environment tips in the comments.
evious
/
opencode-voice-dictation
Offline voice dictation and read-aloud for OpenCode Desktop (Windows)
Dictado por voz para OpenCode Desktop y TUI
Plugin de OpenCode V2 que añade voz a la app de
escritorio y a la TUI:
-
Dictado: pulsas la píldora y se abre el dictado de Windows 11 (Win+H)
que escribe en el prompt con su motor neuronal. También puedes usar el motor
offline
System.Speech desde Ajustes.
-
Lectura: pulsa «Leer» y reproduce en voz alta la última respuesta.
-
TUI:
/dictado, /leer y /pausar en la terminal. En Windows usa
Win+H; en Linux graba y transcribe con whisper.cpp. También <leader>d
<leader>v y <leader>p.
-
Dictado preciso: por defecto delega en Windows Voice Typing (Win+H).
-
Modo offline:
System.Speech sigue disponible como alternativa sin
conexión y sin depender del dictado de Windows.
-
Linux nativo: en Ubuntu,
whisper.cpp transcribe en la CPU sin WSL ni
Python. Ver la guía.
-
Sin portapapeles en Desktop: la lectura usa…
Top comments (0)