Simple TTS for OpenCode using Kokoro TTS.
Experimental. This plugin is still in testing. For now, it is intended for power users only - I need feedback. Confirmed working on TUI, unsure about the other flavours.
- Speaks assistant responses in message or idle mode
- Local CPU or HTTP GPU backend
- Toggle via
/tts-onand/tts-off - Switch profiles via
/tts-profile <name> - Cross-platform playback
- 11 voice options
TTS only runs for main sessions. Child/subagent sessions are ignored. Messages do not overlap; a new message cuts off the previous audio.
TTS starts disabled by default. Enable it with /tts-on once the plugin is loaded.
Add the path manually to your opencode.json, pointing at wherever you copied the plugin:
{
"plugin": ["file:///home/igorw/Work/opencode/.opencode/plugin/tts-reader/src/index.ts"]
}The built-in slash commands are registered directly by the plugin at startup.
On first use, the plugin downloads the Kokoro TTS model (~87MB). You'll see a toast notification when ready.
- Start the Kokoro-FastAPI server with GPU:
# NVIDIA GPU (CUDA)
docker run -d --gpus all -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-gpu:latest
# CPU fallback (no GPU)
docker run -d -p 8880:8880 ghcr.io/remsky/kokoro-fastapi-cpu:latest- Configure the plugin to use HTTP backend by editing
~/.config/opencode/tts.jsoncor switching profiles:
/tts-profile kokoro-gpu- Linux - Tested on Omarchy
- macOS - Should work (afplay built-in)
- Windows - Should work (PowerShell built-in, ffmpeg recommended)
The plugin uses cascading fallbacks to find an available audio player. It tries OS-bundled tools first, then common third-party options:
Linux (tried in order):
ffplay(from ffmpeg - most compatible with HTTP engine)mpv(if installed)paplay(PulseAudio)aplay(ALSA)
macOS (tried in order):
ffplay(from ffmpeg)afplay(built-in)
Windows (tried in order):
ffplay(from ffmpeg - recommended for HTTP engine)Media.SoundPlayer(PowerShell built-in - strict WAV format)wmplayer(Windows Media Player - if installed)
Note on HTTP/GPU mode: The HTTP engine returns WAV files that may not play with Windows' built-in Media.SoundPlayer. Installing ffmpeg is strongly recommended for Windows users using the HTTP backend.
Installation:
- macOS:
brew install ffmpeg - Windows:
winget install ffmpeg(orwinget install ffmpeg.Gyan) - Linux:
sudo apt install ffmpeg
- Docker with NVIDIA GPU support (nvidia-docker2)
- Or any machine running Kokoro-FastAPI (can be remote)
Defaults are stored at ~/.config/opencode/tts.jsonc on first run. Edit that file to customize profiles and settings.
You can switch between defined profiles at runtime using the /tts-profile command:
/tts-profile openai
/tts-profile kokoro-gpuThe slash command templates are embedded in the plugin. The markdown files in command/ are kept as a human-readable reference.
- Trusted Backends: The plugin sends text data to the configured
httpUrl. Ensure you trust the backend server, especially when using remote APIs. - Provider Options: The
providerOptionsfield in profiles allows passing raw JSON to the backend. These are passed without validation and can override core fields likemodelorvoice. - Authentication: Use
httpHeadersto securely pass API keys or Bearer tokens to remote providers.
/tts-on: Enable the reader/tts-off: Disable the reader/tts-profile <name>: Switch to a different backend/voice profile/tts toggle: Invert the current state (default)/tts profile <name>: Alternative syntax for profiles (if/ttscommand file is present)
