SuperAPI AI 工具集

whisper-mlx-local

通用与其它

查看项目

更新于 10-16 07:11

技能介绍

用途

whisper-mlx-local 用于在本地 Mac 上为 Telegram、WhatsApp 等渠道的语音消息提供免费的语音转文字能力。它基于 MLX Whisper 在 Apple Silicon 上运行,目标是替代按分钟计费的语音转录 API(如 OpenAI Whisper、Groq、AssemblyAI),从而消除转录成本。

主要能力

  • 免费:本地运行,无 API 费用。
  • 隐私:音频不会离开本机。
  • 速度:单条消息约 1 秒。
  • 离线:无需联网即可工作。
  • 翻译:支持任意语言转英文(通过 --translate 参数)。
  • 接口:守护进程运行在 localhost:8787,提供 /transcribe 接口。

使用方式

  1. 安装依赖:
pip3 install -r requirements.txt
  1. 启动守护进程:
python3 scripts/daemon.py

首次运行会下载 Whisper 模型(约 1.5GB),需等待出现 “Ready” 提示。

  1. 添加到 OpenClaw 配置(~/.openclaw/openclaw.json):
{
  "tools": {
    "media": {
      "audio": {
        "enabled": true,
        "models": [
          {
            "type": "cli",
            "command": "~/.openclaw/workspace/skills/local-whisper/scripts/transcribe.sh",
            "args": ["{{MediaPath}}"],
            "timeoutSeconds": 60
          }
        ]
      }
    }
  }
}
  1. 重启网关:
openclaw gateway restart

完成后,来自 Telegram、WhatsApp 等渠道的语音消息将在本地免费转录。

手动测试:

./scripts/transcribe.sh voice_message.ogg

翻译为英文:

./scripts/transcribe.sh spanish_audio.ogg --translate

API 调用示例:

curl -X POST http://localhost:8787/transcribe -F "file=@audio.ogg"
# {"text": "Hello world", "language": "en"}

登录时自动启动:

cp com.local-whisper.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.local-whisper.plist

适用场景

  • 需要大量转录 Telegram 语音消息、希望避免按分钟付费的用户。
  • 对隐私敏感、不希望音频上传到云端的场景。
  • 需要在离线环境下进行语音转文字的场景。
  • 已使用 OpenClaw 并希望替换现有 tools.media.audio 转录配置的用户。

限制与注意事项

  • 仅支持 macOS 且需 Apple Silicon(M1/M2/M3/M4)。
  • 需要 Python 3.9+。
  • 首次运行需下载约 1.5GB 模型,耗时较长。
  • 首次转录较慢,模型加载进内存约需 10-30 秒,之后才会即时完成。
  • 若已在用 OpenAI API 进行转录,需用上述配置替换现有的 tools.media.audio 配置。
  • 许可证:MIT。