wechat-voice-send-guide.md
2.71 KB
WeChat 语音发送指南(给 Hermes Agent)
核心原则
不要自己实现 SILK 编码,不要调 edge-tts,不要写 ffmpeg 命令。 调一个 MCP 工具就完成全部工作。
发语音的正确姿势
最简单:文字直接发语音
# Hermes 调用:
result = await mcp.call("send_wechat_voice_tts", {
"to": "filehelper", # 联系人 wxid,测试只用 filehelper
"text": "你好,明天下午三点开会。",
"voice": "zh-CN-XiaoxiaoNeural" # 可选,默认女声
})
# result: {"status": "sent", "to": "filehelper", "duration_ms": 3240, ...}
管线在工具内部自动完成:
text → edge-tts(MP3) → ffmpeg(16kHz PCM) → silk-wasm(SILK V3) → SEND_VOICE_INTERNAL 广播 → WeChat DB status=4
换男声
result = await mcp.call("send_wechat_voice_tts", {
"to": "filehelper",
"text": "今日摘要已生成,请查看。",
"voice": "zh-CN-YunxiNeural" # 男声
})
可用声音列表:
zh-CN-XiaoxiaoNeural— 晓晓,女,自然zh-CN-YunxiNeural— 云希,男,自然zh-CN-YunyangNeural— 云扬,男,新闻播报风
如果你已经有 SILK 文件
result = await mcp.call("send_wechat_voice", {
"to": "filehelper",
"silk_path": "/data/local/tmp/my_voice.amr",
"duration_ms": 4500
})
安全约束
IMPORTANT: 测试阶段只对 filehelper(文件传输助手)发送,不要对真实联系人发语音。
发文字消息
result = await mcp.call("send_wechat_message", {
"to": "filehelper",
"content": "你好"
})
依赖(第一次使用前确认已安装)
在 Termux 里执行:
pip install edge-tts
pkg install ffmpeg nodejs
npm install -g silk-wasm
验证:
python3 -c "import edge_tts; print('OK')"
ffmpeg -version | head -1
node -e "require('silk-wasm'); console.log('OK')"
常见错误
| 错误信息 | 原因 | 解决 |
|---|---|---|
edge-tts not installed |
pip 未装 | pip install edge-tts |
ffmpeg not found |
未装 ffmpeg | pkg install ffmpeg |
silk-wasm not found |
未装 | npm install -g silk-wasm |
WeChat not running |
微信进程未启动 | 工具会自动启动,等 10s 重试 |
failed to stage SILK |
权限问题 | 确认 Magisk root 正常 |
技术背景(不需要懂,只需要调工具)
- WeChat 语音消息 = SILK V3 格式(Tencent 变体,
\x02#!SILK_V3前缀) - 通过 LSPosed hook(wechathook 模块)注入 WeChat 内部
w11.r0工厂 - DB INSERT 在 r0 构造器内完成,status=4(已送达),不触发 CDN 上传
- 不是 UI 模拟,不影响微信界面,不会被 WeChat 反自动化检测