global claude code voice mode

This commit is contained in:
David Chen 2025-08-28 18:20:16 -07:00
parent b2ce6e7598
commit af834a4619
8 changed files with 66 additions and 33 deletions

3
.gitignore vendored
View file

@ -65,3 +65,6 @@ yazi/bookmark
# Deploy script
!/deploy.sh
# Raycast scripts directory
!/raycast-scripts/

View file

@ -28,11 +28,18 @@ If you need to install Homebrew manually:
### Claude Code Voice Configuration
This config includes a directory-based voice system for Claude Code that uses macOS text-to-speech.
This config includes a global voice system for Claude Code that uses macOS text-to-speech.
#### Voice Commands
- `/voice-on` - Enable text-to-speech for current directory
- `/voice-off` - Disable text-to-speech for current directory
- `/voice-on` - Enable text-to-speech globally
- `/voice-off` - Disable text-to-speech globally
#### Raycast Integration
For quick voice control, use the included Raycast scripts:
- **"Toggle Claude Voice"** - Toggle voice on/off from anywhere
- **"Stop Voice (TTS)"** - Immediately stop any playing speech
To add to Raycast: Add the `raycast-scripts/` directory to your Raycast script directories.
#### Selecting and Downloading High Quality System Voices
@ -46,8 +53,8 @@ For the best text-to-speech experience, download high-quality system voices:
**Recommended**: Siri voices provide the most natural speech quality but require downloading additional voice data.
#### Voice Database
Voice settings are stored per-directory in `~/.claude/voice-db.json` and automatically created by the scripts.
#### Voice Settings
Voice is controlled by a global flag file at `~/.claude/voice-enabled`. When this file exists, Claude Code will speak all responses.
### Other Applications
- **tmux**: Terminal multiplexer with custom configuration

View file

@ -30,11 +30,18 @@
### Claude Code 语音配置
此配置包含一个基于目录的 Claude Code 语音系统,使用 macOS 文本转语音功能。
此配置包含一个全局的 Claude Code 语音系统,使用 macOS 文本转语音功能。
#### 语音命令
- `/voice-on` - 为当前目录启用文本转语音
- `/voice-off` - 为当前目录禁用文本转语音
- `/voice-on` - 全局启用文本转语音
- `/voice-off` - 全局禁用文本转语音
#### Raycast 集成
为了快速语音控制,使用包含的 Raycast 脚本:
- **"Toggle Claude Voice"** - 从任何地方切换语音开/关
- **"Stop Voice (TTS)"** - 立即停止任何正在播放的语音
添加到 Raycast`raycast-scripts/` 目录添加到您的 Raycast 脚本目录。
#### 选择和下载高质量系统语音
@ -48,8 +55,8 @@
**推荐**: Siri 语音提供最自然的语音质量,但需要下载额外的语音数据。
#### 语音数据库
语音设置按目录存储在 `~/.claude/voice-db.json` 中,由脚本自动创建
#### 语音设置
语音由全局标志文件 `~/.claude/voice-enabled` 控制。当此文件存在时Claude Code 将朗读所有响应
### 其他应用程序
- **tmux**: 带有自定义配置的终端复用器

View file

@ -1,11 +0,0 @@
#!/bin/bash
current_dir=$(pwd)
voice_db="$HOME/.claude/voice-db.json"
# Create voice database if it doesn't exist
if [ ! -f "$voice_db" ]; then
echo "{}" > "$voice_db"
fi
jq --arg dir "$current_dir" '.[$dir] = false' "$voice_db" > /tmp/voice-db-temp.json && mv /tmp/voice-db-temp.json "$voice_db"
echo "Voice disabled for $current_dir"

View file

@ -1,11 +0,0 @@
#!/bin/bash
current_dir=$(pwd)
voice_db="$HOME/.claude/voice-db.json"
# Create voice database if it doesn't exist
if [ ! -f "$voice_db" ]; then
echo "{}" > "$voice_db"
fi
jq --arg dir "$current_dir" '.[$dir] = true' "$voice_db" > /tmp/voice-db-temp.json && mv /tmp/voice-db-temp.json "$voice_db"
echo "Voice enabled for $current_dir"

View file

@ -12,7 +12,7 @@
"hooks": [
{
"type": "command",
"command": "current_dir=$(pwd); voice_db=\"$HOME/.claude/voice-db.json\"; if [ -f \"$voice_db\" ] && [ \"$(jq -r --arg dir \"$current_dir\" '.[$dir] // false' \"$voice_db\")\" = \"true\" ]; then transcript_path=$(cat | jq -r '.transcript_path'); nohup bash -c 'tail -1 \"'$transcript_path'\" | jq -r \".message.content[0].text // empty\" | say' >/dev/null 2>&1 & fi"
"command": "voice_flag=\"$HOME/.claude/voice-enabled\"; if [ -f \"$voice_flag\" ]; then transcript_path=$(cat | jq -r '.transcript_path'); pkill -f 'say' 2>/dev/null; nohup bash -c 'tail -1 \"'$transcript_path'\" | jq -r \".message.content[0].text // empty\" | say' >/dev/null 2>&1 & fi"
}
]
}

View file

@ -0,0 +1,23 @@
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Toggle Claude Voice
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🔊
# @raycast.description Toggle Claude Code voice on/off globally
voice_flag="$HOME/.claude/voice-enabled"
if [ -f "$voice_flag" ]; then
# Voice is currently on, turn it off
rm -f "$voice_flag"
pkill -f 'say' 2>/dev/null
echo "Claude Voice OFF"
else
# Voice is currently off, turn it on
touch "$voice_flag"
echo "Claude Voice ON"
fi

View file

@ -0,0 +1,15 @@
#!/bin/bash
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Stop Voice (TTS)
# @raycast.mode compact
# Optional parameters:
# @raycast.icon 🔇
# @raycast.description Stop all text-to-speech playback
# Kill all running say processes
pkill -f 'say' 2>/dev/null
echo "All TTS stopped"