mirror of
https://github.com/theniceboy/.config.git
synced 2026-07-16 22:01:21 +08:00
global claude code voice mode
This commit is contained in:
parent
b2ce6e7598
commit
af834a4619
8 changed files with 66 additions and 33 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -65,3 +65,6 @@ yazi/bookmark
|
||||||
|
|
||||||
# Deploy script
|
# Deploy script
|
||||||
!/deploy.sh
|
!/deploy.sh
|
||||||
|
|
||||||
|
# Raycast scripts directory
|
||||||
|
!/raycast-scripts/
|
||||||
|
|
|
||||||
17
README.md
17
README.md
|
|
@ -28,11 +28,18 @@ If you need to install Homebrew manually:
|
||||||
|
|
||||||
### Claude Code Voice Configuration
|
### 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 Commands
|
||||||
- `/voice-on` - Enable text-to-speech for current directory
|
- `/voice-on` - Enable text-to-speech globally
|
||||||
- `/voice-off` - Disable text-to-speech for current directory
|
- `/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
|
#### 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.
|
**Recommended**: Siri voices provide the most natural speech quality but require downloading additional voice data.
|
||||||
|
|
||||||
#### Voice Database
|
#### Voice Settings
|
||||||
Voice settings are stored per-directory in `~/.claude/voice-db.json` and automatically created by the scripts.
|
Voice is controlled by a global flag file at `~/.claude/voice-enabled`. When this file exists, Claude Code will speak all responses.
|
||||||
|
|
||||||
### Other Applications
|
### Other Applications
|
||||||
- **tmux**: Terminal multiplexer with custom configuration
|
- **tmux**: Terminal multiplexer with custom configuration
|
||||||
|
|
|
||||||
17
README_cn.md
17
README_cn.md
|
|
@ -30,11 +30,18 @@
|
||||||
|
|
||||||
### Claude Code 语音配置
|
### Claude Code 语音配置
|
||||||
|
|
||||||
此配置包含一个基于目录的 Claude Code 语音系统,使用 macOS 文本转语音功能。
|
此配置包含一个全局的 Claude Code 语音系统,使用 macOS 文本转语音功能。
|
||||||
|
|
||||||
#### 语音命令
|
#### 语音命令
|
||||||
- `/voice-on` - 为当前目录启用文本转语音
|
- `/voice-on` - 全局启用文本转语音
|
||||||
- `/voice-off` - 为当前目录禁用文本转语音
|
- `/voice-off` - 全局禁用文本转语音
|
||||||
|
|
||||||
|
#### Raycast 集成
|
||||||
|
为了快速语音控制,使用包含的 Raycast 脚本:
|
||||||
|
- **"Toggle Claude Voice"** - 从任何地方切换语音开/关
|
||||||
|
- **"Stop Voice (TTS)"** - 立即停止任何正在播放的语音
|
||||||
|
|
||||||
|
添加到 Raycast:将 `raycast-scripts/` 目录添加到您的 Raycast 脚本目录。
|
||||||
|
|
||||||
#### 选择和下载高质量系统语音
|
#### 选择和下载高质量系统语音
|
||||||
|
|
||||||
|
|
@ -48,8 +55,8 @@
|
||||||
|
|
||||||
**推荐**: Siri 语音提供最自然的语音质量,但需要下载额外的语音数据。
|
**推荐**: Siri 语音提供最自然的语音质量,但需要下载额外的语音数据。
|
||||||
|
|
||||||
#### 语音数据库
|
#### 语音设置
|
||||||
语音设置按目录存储在 `~/.claude/voice-db.json` 中,由脚本自动创建。
|
语音由全局标志文件 `~/.claude/voice-enabled` 控制。当此文件存在时,Claude Code 将朗读所有响应。
|
||||||
|
|
||||||
### 其他应用程序
|
### 其他应用程序
|
||||||
- **tmux**: 带有自定义配置的终端复用器
|
- **tmux**: 带有自定义配置的终端复用器
|
||||||
|
|
|
||||||
|
|
@ -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"
|
|
||||||
|
|
@ -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"
|
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
"hooks": [
|
"hooks": [
|
||||||
{
|
{
|
||||||
"type": "command",
|
"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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
raycast-scripts/claude-code-voice-toggle.sh
Executable file
23
raycast-scripts/claude-code-voice-toggle.sh
Executable 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
|
||||||
15
raycast-scripts/stop-voice-tts.sh
Executable file
15
raycast-scripts/stop-voice-tts.sh
Executable 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"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue