An OpenCode plugin that adds text-to-speech capabilities using ElevenLabs v3 with expressive audio tags.
https://x.com/placeholder-demo-link
- ElevenLabs v3 - Uses the most expressive TTS model with audio tag support
- Audio Tags - Control emotions, delivery, reactions, accents, and sound effects inline
- Non-blocking - Audio plays in background, control returns immediately
- macOS Native - Uses
afplayfor reliable audio playback
Run this one-liner to install and configure everything:
curl -fsSL https://raw.githubusercontent.com/anomalyco/opencode-voice/main/setup.sh | bashThe setup script will:
- Clone the plugin to
~/dev/opencode-voice - Install dependencies
- Prompt for your ElevenLabs API key
- Update your OpenCode config
Then restart OpenCode!
Click to expand manual steps
- Clone or download this plugin:
git clone https://github.com/anomalyco/opencode-voice.git ~/dev/opencode-voice
cd ~/dev/opencode-voice
bun install- Add your ElevenLabs API key:
mkdir -p ~/.config/opencode/secrets
echo "YOUR_API_KEY" > ~/.config/opencode/secrets/elevenlabs-key- Register the plugin in your OpenCode config (
~/.config/opencode/opencode.json):
{
"plugin": [
"file:///Users/YOUR_USERNAME/dev/opencode-voice"
]
}- Restart OpenCode
The plugin provides a speak tool that converts text to speech with expressive audio tags:
speak("[excited] Hello! [laughs] This is amazing!")
speak("[whispers] Something's coming... [sighs] I can feel it.")
speak("[dramatically] The code is complete.")
ElevenLabs v3 supports inline audio tags for precise control:
| Category | Examples |
|---|---|
| Emotions | [laughs], [sighs], [excited], [sad], [angry], [happily], [sarcastic], [curious] |
| Delivery | [whispers], [shouts], [dramatically], [calmly], [nervously] |
| Reactions | [laughs harder], [giggles], [clears throat], [gasps], [gulps] |
| Accents | [strong French accent], [British accent], [Southern US accent] |
| Sound FX | [applause], [gunshot], [explosion] |
| Parameter | Type | Default | Description |
|---|---|---|---|
text |
string | required | Text with optional audio tags |
stability |
0-1 | 0.5 | Lower = more expressive |
similarity_boost |
0-1 | 0.75 | Voice similarity |
speed |
0.5-2.0 | 1.0 | Speech speed |
volume |
0-2 | 1.0 | Playback volume |
- Use in short bursts to notify the user of important state changes
- Good for: task completion, errors requiring attention, questions needing user input
- Keep messages concise (1-2 sentences) - don't read entire responses aloud
Examples:
[excited] Done! The build succeeded.[curious] I have a question - should I proceed with the refactor?[sighs] I found 3 errors we need to fix.[whispers] Heads up - I'm about to make a breaking change.
The default voice ID is YOq2y2Up4RgXP2HyXjE5. To use a different voice, edit src/plugin.ts:
const VOICE_ID = "your-voice-id-here";The plugin reads the ElevenLabs API key from:
~/.config/opencode/secrets/elevenlabs-key
- macOS (uses
afplayfor audio playback) - Bun runtime
- ElevenLabs API key with v3 access
MIT