语音转录服务

通过本地或远程服务器上的Whisper进行语音转录,支持Claude Code通过SSH/tmux环境进行远程语音输入。

  • by NimbusCG
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 NimbusCG/voice-dictation-mcp

使用说明

克劳德密码语音听写

通过SSH/tmux在远程服务器上运行的Claude Code的语音输入。

在本地计算机上录制音频→ 由Whisper转录(本地或服务器上)→ Claude Code通过以下方式阅读 /dictate.

建筑

[Windows machine]                              [Remote server (castellatus)]

Option A: Local transcription (--local, faster)
voice_recorder.py --local                      ~/voice/
  records audio                                  transcripts/{channel}/latest.txt ← written directly
  transcribes with Whisper ──→ V:\ mount ──→       ↑
                                                   reads
  "/dictate" in Claude Code ←─────────────────  /dictate skill

Option B: Remote transcription (default)
voice_recorder.py                              ~/voice/
  records audio ──→ V:\ mount ──→                incoming/{channel}/*.wav
                                                    ↓ inotifywait + faster-whisper
                                                 transcripts/{channel}/latest.txt
                                                    ↑
  "/dictate" in Claude Code ←── skill/MCP ──→   mcp_voice_server.py

快速入门(Windows)

# 1. Mount remote voice folder as V:
net use V: \\sshfs.k\ubuntu@castellatus.cloudgrow.tech\voice

# 2. Install dependencies
C:\Python314\python.exe -m pip install sounddevice soundfile faster-whisper

# 3. Run with local transcription targeting a Claude Code session
C:\Python314\python.exe V:\voice_recorder.py --channel monitoring --local

# 4. In Claude Code on the server, type: /dictate

转录模式

本地转录(--local)--推荐

Whisper在您的Windows计算机上运行。转录文本直接写入SSHFS安装架。更快,因为不需要.wav上传或服务器端处理。

C:\Python314\python.exe V:\voice_recorder.py --channel monitoring --local
C:\Python314\python.exe V:\voice_recorder.py --channel monitoring --local --model small  # more accurate
C:\Python314\python.exe V:\voice_recorder.py --channel monitoring --local --model tiny   # fastest

要求: pip install faster-whisper (首次运行时下载约150MB型号)

远程转录(默认)

将.wav上传到服务器。这 transcribe_watcher.sh 该服务在Whisper服务器端接收并转录。

C:\Python314\python.exe V:\voice_recorder.py --channel monitoring

除此之外不需要额外的Python依赖项 sounddevice soundfile.

SCP模式(无SSHFS安装)

如果您无法挂载V:,请使用 windows_recorder.py 通过SCP上传:

python windows_recorder.py --channel monitoring

组件

文件 位置 目的
voice_recorder.py 本地(Windows/Mac/Linux) 录制音频, --local 对于当地的Whisper来说, --channel 目标tmux会话
windows_recorder.py 本地(Windows) 录制音频,通过SCP上传(无需挂载)
mcp_voice_server.py 远程服务器 MCP服务器暴露 dictate 工具--自动检测tmux会话
transcribe_watcher.sh 远程服务器 监视新的.wav文件,用Whisper转录
voice-watcher.service 远程服务器 监视器的systemd服务

通道=tmux会话

每个Claude Code会话都会自动绑定到其 tmux会话名称 作为语音通道。

tmux会话 记录器 --channel 成绩单位置
production-main --channel production-main ~/voice/transcripts/production-main/latest.txt
monitoring --channel monitoring ~/voice/transcripts/monitoring/latest.txt
0 (默认tmux) --channel 0 ~/voice/transcripts/0/latest.txt
(无tmux) (无旗) ~/voice/transcripts/default/latest.txt

服务器端 --MCP服务器和 /dictate skill自动检测tmux会话名称。

记录器侧 --您可以选择要针对哪个会话 --channel.

设置

远程服务器

# Install dependencies
python3 -m venv ~/voice/venv
source ~/voice/venv/bin/activate
pip install faster-whisper
sudo apt install ffmpeg inotify-tools

# Install and start watcher service (for remote transcription mode)
sudo cp voice-watcher.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now voice-watcher

# MCP server config (~/.claude/settings.json) — channel auto-detected from tmux
# "mcpServers": {
#   "voice-dictation": {
#     "command": "python3",
#     "args": ["/home/ubuntu/voice/mcp_voice_server.py"]
#   }
# }

本地计算机(Windows)

# Install WinFsp + SSHFS-Win
#   https://winfsp.dev
#   https://github.com/winfsp/sshfs-win

# Mount remote voice folder as V:
net use V: \\sshfs.k\ubuntu@castellatus.cloudgrow.tech\voice

# Install Python dependencies
C:\Python314\python.exe -m pip install sounddevice soundfile

# For local transcription mode (recommended):
C:\Python314\python.exe -m pip install faster-whisper

用法

  1. 在Windows上启动刻录机: C:\Python314\python.exe V:\voice_recorder.py --channel monitoring --local
  2. 按回车→ 说→ 按回车
  3. 在服务器上的Claude Code中,键入 /dictate
  4. 克劳德阅读你的口语文本并采取行动

这 /dictate skill会自动检测tmux会话,读取记录,并将口语文本视为您的指令。每 /dictate 调用会消耗记录,因此过时的文本不会被重新读取。

Whisper型号

对于 --local 模式,选择一个模型 --model:

型号 尺寸 速度 精度
tiny ~ 75MB 最快 适用于短命令
base ~150MB 快速 默认,平衡良好
small ~500MB 中等 精度更高
medium ~1.5GB 慢 最佳精度