Make Claude Code speak its responses using local text-to-speech.
Every time Claude finishes responding, the hook automatically:
- Extracts the response text
- Strips markdown formatting
- Sends it to a local TTS server
- Plays the audio
Works with any OpenAI-compatible TTS API. Designed for Vois, but compatible with any TTS server that follows the OpenAI /v1/audio/speech format.
- Claude Code (Anthropic's CLI)
- jq - JSON processor (
brew install jq,apt install jq, orchoco install jq) - curl - HTTP client (pre-installed on macOS/Linux, available in Git Bash on Windows)
- Audio player -
afplay(macOS),aplay/paplay(Linux), PowerShell (Windows) - TTS server - Vois or any OpenAI-compatible TTS API
The script runs on Windows via Git Bash or WSL. Git Bash is included with Git for Windows. Audio playback uses PowerShell automatically when running in MINGW/MSYS/Cygwin environments.
git clone https://github.com/praneybehl/claude-code-voice-hook.git
cd claude-code-voice-hook
./install.sh- Copy the hook script:
mkdir -p ~/.claude/hooks
cp speak-response.sh ~/.claude/hooks/
chmod +x ~/.claude/hooks/speak-response.sh- Add to
~/.claude/settings.json:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "bash ~/.claude/hooks/speak-response.sh",
"timeout": 180
}
]
}
]
}
}Set environment variables to customize behavior:
| Variable | Default | Description |
|---|---|---|
VOIS_API_URL |
http://localhost:8080/v1/audio/speech |
TTS API endpoint |
VOIS_API_KEY |
(empty) | API key if required |
VOIS_VOICE |
af_heart |
Voice ID to use |
VOIS_ENABLED |
1 |
Set to 0 to disable |
VOIS_MAX_CHARS |
1500 |
Max characters to speak |
Example:
export VOIS_VOICE="bf_emma"
export VOIS_MAX_CHARS="2000"Vois includes 54 voices across 10 languages. Popular choices:
| Voice ID | Description |
|---|---|
af_heart |
Warm, conversational American female |
af_alloy |
Neutral, professional American female |
am_adam |
Clear, authoritative American male |
bf_emma |
Natural British female |
bm_george |
Professional British male |
See the full voice library in the Vois app or at vois.so/features/voices.
Claude Code supports hooks - shell commands that run at specific lifecycle events. The Stop hook fires after Claude finishes generating a response.
The hook:
- Reads JSON from stdin containing the transcript path
- Parses the transcript to find the last assistant message
- Strips markdown (code blocks become "[code block]")
- Truncates to max characters
- POSTs to the TTS API
- Plays the resulting WAV file
./uninstall.shOr manually:
rm ~/.claude/hooks/speak-response.sh
# Remove the Stop hook from ~/.claude/settings.jsonNo audio plays
- Check that your TTS server is running
- Verify the API URL:
curl http://localhost:8080/health - Check that
jqis installed:jq --version
Audio is choppy or slow
- The TTS runs after Claude responds, so long responses take time
- Reduce
VOIS_MAX_CHARSfor faster playback
Want to disable temporarily
export VOIS_ENABLED=0For a detailed guide on adding voice output to AI coding agents (Claude Code, Claude Desktop, Codex CLI, and more), check out the blog post:
Getting AI Coding Agents to Talk: Voice Output for Claude Code, Desktop & Beyond
MIT License - see LICENSE
Built for use with Vois - the local AI voice studio.