基于本地 Ollama 的语音识别输入工具,在 Mac mini 上通过语音进行输入。
- 🎤 按住录音 - 通过菜单栏操作开始/停止录音
- 🔊 本地识别 - 使用 whisper.cpp 本地语音识别,完全离线
- ✨ 智能标点 - 自动添加标点符号
- 📋 自动粘贴 - 自动将识别结果粘贴到焦点输入框
- 🍎 macOS 原生 - 菜单栏应用,轻量高效
┌─────────────────────────────────────────┐
│ 菜单栏 UI (rumps) │
└─────────────────┬───────────────────────┘
│
┌─────────────────▼───────────────────────┐
│ 音频录制 (sox) │
└─────────────────┬───────────────────────┘
│
┌─────────────────▼───────────────────────┐
│ 语音识别 (whisper.cpp) │
└─────────────────┬───────────────────────┘
│
┌─────────────────▼───────────────────────┐
│ 标点优化 (简单规则) │
└─────────────────┬───────────────────────┘
│
┌─────────────────▼───────────────────────┐
│ 全局输入 (pyperclip + osascript) │
└─────────────────────────────────────────┘
- macOS
- Python 3.11+
- Ollama
- sox (音频录制)
- whisper.cpp 模型
cd ~/Projects
git clone <your-repo-url> voice-input
cd voice-inputpip install -r requirements.txt
brew install soxmkdir -p ~/.voice-input/models
# 下载 medium 中文模型 (约 1.5GB)
curl -L -o ~/.voice-input/models/ggml-medium.bin \
"https://huggingface.co/ggerganov/whisper.cpp/resolve/main/ggml-medium.bin"ollama servepython3 main_menu.py- 点击菜单栏的 🎤 图标
- 选择 "🎤 开始录音"
- 对着麦克风说话
- 选择 "⏹ 停止录音"
- 自动识别并粘贴到当前焦点输入框
| 图标 | 状态 |
|---|---|
| 🎤 | 就绪 |
| 🔴 | 录音中 |
| ⚙️ | 识别中 |
| 📝 | 粘贴中 |
| ✅ | 完成 |
| ❌ | 错误 |
配置文件位于 ~/.voice-input/config.yaml:
whisper_model: "medium" # whisper 模型
ollama_host: "http://localhost:11434"
preview_timeout: 30 # 预览超时(秒)
audio_temp_dir: "~/.voice-input"voice-input/
├── main_menu.py # 菜单栏版本(推荐)
├── main_simple.py # 窗口版本
├── main.py # 完整版(需要全局热键权限)
├── audio/
│ └── recorder.py # 音频录制
├── recognition/
│ └── whisper_client.py # whisper.cpp 调用
├── nlp/
│ └── ollama_client.py # 标点优化
├── input/
│ └── global_input.py # 全局输入
├── ui/
│ ├── status_window.py # 悬浮状态窗口
│ ├── preview_window.py # 预览确认窗口
│ └── ui_manager.py # UI 管理器
└── utils/
└── hotkey.py # 全局快捷键
- 全局热键 Option+S 需要 macOS 辅助功能权限
- 标点优化使用简单规则,大模型调用较慢
MIT