discord-opencode-plugin
OpenCode V2github
local ASRnode 24 daemonrust · metalinput audio stays local

Discord voice bridgeOpenCode V2

OpenCode, in the voice channel.

A bot joins a Discord voice channel, transcribes every speaker locally on the Mac GPU with Parakeet Ultra, and forwards the conversation to a real OpenCode session. The agent decides what to say and speaks back through one tool: voice_speak.

install
npx discord-opencode-live

ASR
Parakeet Ultra · Metal
Runtime
Node 24 daemon
Speech
voice_speak only
Input
stays on the machine
  • Discord voiceopus, per user
  • daemon16 kHz mono
  • asr-serverMetal
  • sessionprompt
  • voice_speakedge-tts

Two ways to be in the channel.

The bot stays connected until /voice-stop. The mode decides what actually reaches the agent.

live

/voice-startalias /start

Every finished human turn is queued to the pinned session.

Turns are aggregated by a 400 ms speech gap, so a quick exchange becomes one prompt instead of three. While someone is still talking, the last 2.5 s are decoded every 800 ms and published as partial events. Partials never wake the agent: only the finished utterance does.

wake

/voice-wakeno alias

Only when someone says “Elia”.

Chatter stays in a rolling buffer in RAM. Saying “Elia” flushes the last 3 minutes into the session as context and opens a 120 s engagement window, extended by speech. Stop phrases close it. Nothing is sent to the agent while people talk to each other.

The bot’s own audio is never subscribed to, so there is no self-transcription loop. Human speech also stops playback: barge-in is immediate.

Three processes, one signal path.

OpenCode V2 plugins run inside the OpenCode server under Bun. Discord voice needs native Node addons, proven under Node 24. Rather than load them inside Bun, the bridge is split into a sidecar daemon and a Rust ASR server.

  1. Discord voiceopus, per user
  2. daemon16 kHz mono
  3. asr-servertext
  4. pluginprompt
  5. sessionagent turn

plugin/

Bun · TypeScript

OpenCode V2 server plugin

  • 7 commands, 7 tools
  • session injection
  • daemon lifecycle
  • SSE to ctx.session.prompt

daemon/

Node 24

Discord gateway and audio sidecar

  • voice receive, opus decode
  • energy VAD and turn aggregation
  • wake logic and rolling buffer
  • edge-tts streaming
  • local HTTP API + SSE

asr-server/

Rust · Metal

Parakeet Ultra GGUF, loaded once

  • 16 kHz mono PCM in
  • transcribe-cpp 0.5.2
  • one model per process
  • text out over localhost

One model is loaded at a time. Qwen3-ASR was benchmarked on the same server and kept on disk as an offline option, never loaded alongside Parakeet.

Four choices that shape everything.

These are the constraints the rest of the code follows. Each one removes a failure mode rather than adding a feature.

  1. Audio never leaves the machine.

    Opus is decoded and resampled locally, Parakeet runs on the Metal GPU, and the rolling transcript lives in RAM only. TTS streams from edge-tts to the player without writing a file; the file-based fallback deletes its temp directory after playback.

  2. Speaker identity comes from the transport layer.

    Discord delivers one independent PCM stream per user, so the speaker is known before any model runs. No diarization. Every partial and every turn carries a speaker object and the voice channel name.

  3. Exactly one speech path.

    The only way the bot speaks is the voice_speak tool. Assistant text is never parsed or auto-spoken, so it cannot double-speak or talk over itself. The agent decides when to speak; the tool does the rest.

  4. Energy VAD, not Discord’s speaking stop.

    The speaking stop event never fired reliably under DAVE and left utterances open forever. Segmentation is an energy VAD: adaptive noise floor, 60 ms onset, 200 ms pre-roll, 400 ms silence hangover, 28 s cap.

What it costs in seconds.

These numbers come from one Apple M5 with Metal and a persistent ASR server, on French clips. They are measurements from this machine, not a hardware benchmark.

Measured latency on an Apple M5 with Metal, French speech clips
MeasurementResult
Parakeet Ultra · 6.2 s clip0.6 – 1.0 sfull utterance decode
Parakeet Ultra · 26.4 s clip1.9 – 3.4 sroughly 8–14× real time, depending on GPU load
Tail window · 2.5 s0.3 – 1.0 sdecoded every 800 ms while speech is active
edge-tts · first MP3 byte1.6 – 2.0 s1.9 – 2.8 s total for a short sentence
Speech end → agent injection~1.4 – 1.8 s400 ms hangover + 400 ms aggregation + ASR; the model’s own time is extra

Qwen3-ASR 1.7B was benchmarked through the same server and the same clips: same French words, 8.3 s for the 26.4 s clip. It stays on disk as an offline, high-accuracy option — never as the live engine, and never loaded alongside Parakeet.

The earlier “101 ms / 68×” figure came from a different measurement and is not used anywhere in this project.

Five commands, seven tools.

Both are registered by the plugin, not by markdown files. The commands ship with the code and call the daemon directly.

Commands in the / menu

  • /voice-startalias /start

    Join the channel, start live conversation, pin this session.

  • /voice-stopalias /stop

    Leave the channel and stop listening.

  • /voice-wake

    Join, but only react when someone says “Elia”.

  • /voice-status

    Connection, channel, mode, language, buffer size.

  • /voice-language

    Set ASR + TTS language from an ISO code, persisted to config.

One command, then your server id.

The package installs from npm, registers itself in OpenCode and writes its config. The ASR server still compiles on the machine that runs it, because a Metal binary is not something to ship.

  1. Install with npx

    Installs the package globally, registers the plugin in opencode.json and seeds the config. Backs up opencode.json before touching it. It never joins voice by itself.

    install
    npx discord-opencode-live

  2. Point it at your server

    The seeded config ships with a placeholder guildId. Set yours, and channel if you want to pin one. autoJoin stays false. The bot token is read from your existing MCP config, never from this package.

    {
      "guildId": "your-server-id",
      "channel": ""
    }
  3. Build the ASR server

    The installer compiles it when cargo is present. If it skipped the build, install Rust and run the installer again: it only builds what is missing. doctor reports what the machine lacks.

    build
    npx discord-opencode-live install

  4. Restart OpenCode

    The plugin starts the daemon on first use. /voice-start is an explicit action, never a startup side effect. Then talk, and run /voice-stop to leave.

  5. Upgrade later

    Reads the latest version from npm, reinstalls it globally and re-registers the new path. status tells you what is installed, registered and running; uninstall removes the entry and keeps your config.

    upgrade
    npx discord-opencode-live upgrade

What the machine needs.

The model is already on disk if Handy has run on this Mac. Everything else is a local build dependency.

OS
macOS on Apple Silicon (Metal)
Node
Node 24 — the default node may be v20
Rust
cargo toolchain, for the ASR server
Media
ffmpeg, ffprobe, python3 -m edge_tts
Voice
@discordjs/voice 0.19.2+ and @snazzah/davey for DAVE/E2EE
Model
HandyParakeet Ultra GGUF already in the Handy cache: ~/.cache/huggingface/hub/models--handy-computer--parakeet-ultra-gguf/
Token
Discord bot token read from the existing ~/.config/mcp/mcp_servers.json — never copied into the repo