A plugin for OpenCode that provides text-to-speech (TTS) functionality, allowing the AI assistant to speak responses aloud.
speaktool - AI can call this tool to speak text aloud- Speech lock support - Automatically checks if user is recording before speaking
- HTTP API support - Connects to any TTS server with a simple REST API
- Fallback support - Falls back to shell script if API is unavailable
- Session events - Optional automatic announcements on session completion
- Configurable - Customize via environment variables
git clone https://github.com/Olbrasoft/opencode-voice-plugin.git
cd opencode-voice-pluginnpm install
npm run build# Create plugin directory if it doesn't exist
mkdir -p ~/.config/opencode/plugin
# Create symlink
ln -s /path/to/opencode-voice-plugin/dist/index.js ~/.config/opencode/plugin/voice.jsThe plugin will be loaded automatically on next startup.
Configure the plugin using environment variables:
| Variable | Default | Description |
|---|---|---|
OPENCODE_TTS_API_URL |
http://localhost:5555/api/speech/speak |
TTS API endpoint |
OPENCODE_TTS_CAN_SPEAK_URL |
http://localhost:5555/api/speech/can-speak |
Speech lock check endpoint |
OPENCODE_TTS_FALLBACK_SCRIPT |
~/voice-assistant/voice-output/tts-api.sh |
Fallback shell script |
OPENCODE_TTS_ANNOUNCE_IDLE |
false |
Announce when session becomes idle |
OPENCODE_TTS_IDLE_MESSAGE |
Úkol dokončen. |
Message to speak on idle |
This plugin is designed to work with EdgeTTS WebSocket Server (part of VoiceAssistant project):
# Set your TTS API endpoint
export OPENCODE_TTS_API_URL="http://localhost:5555/api/speech/speak"
export OPENCODE_TTS_CAN_SPEAK_URL="http://localhost:5555/api/speech/can-speak"If you prefer using a shell script for TTS:
# Point to your TTS script
export OPENCODE_TTS_FALLBACK_SCRIPT="/path/to/your/tts-script.sh"Once installed, the AI can use the speak tool to speak text aloud:
AI: I'll confirm this with voice output.
⚙ speak [text=Úkol byl úspěšně dokončen.]
⚙ „Úkol byl úspěšně dokončen."
The output uses Czech quotation marks („") for clean, readable display.
The plugin expects the TTS API to accept POST requests with JSON body:
{
"text": "Text to speak"
}The API should return:
200 OKon success- Any other status code on failure (plugin will use fallback)
npm run buildnpm run watchnpm run cleanMIT License - see LICENSE for details.
Contributions are welcome! Please open an issue or submit a pull request.