whatsappVoiceOpenSkill技能使用说明
2026-04-01
新闻来源:网淘吧
围观:9
电脑广告
手机广告
WhatsApp语音通话
将WhatsApp语音消息转化为实时对话。此技能提供完整处理流程:语音→转写→意图识别→回复生成→文本转语音。
完美适用于:

- WhatsApp语音助手
- 免提指令界面
- 多语言聊天机器人
- 物联网语音控制(无人机、智能家居等)
快速开始
1. 安装依赖项
pip install openai-whisper soundfile numpy
2. 处理语音消息
const { processVoiceNote } = require('./scripts/voice-processor');
const fs = require('fs');
// Read a voice message (OGG, WAV, MP3, etc.)
const buffer = fs.readFileSync('voice-message.ogg');
// Process it
const result = await processVoiceNote(buffer);
console.log(result);
// {
// status: 'success',
// response: "Current weather in Delhi is 19°C, haze. Humidity is 56%.",
// transcript: "What's the weather today?",
// intent: 'weather',
// language: 'en',
// timestamp: 1769860205186
// }
3. 运行自动监听器
用于自动处理传入的WhatsApp语音消息:
node scripts/voice-listener-daemon.js
此功能会监控~/.clawdbot/media/inbound/目录,每5秒检测并处理新的语音文件。
工作原理
Incoming Voice Message
↓
Transcribe (Whisper API)
↓
"What's the weather?"
↓
Detect Language & Intent
↓
Match against INTENTS
↓
Execute Handler
↓
Generate Response
↓
Convert to TTS
↓
Send back via WhatsApp
核心功能
✅零配置复杂度- 无需FFmpeg,无需复杂依赖。使用soundfile + Whisper。
✅多语言支持- 自动检测英语/印地语。易于扩展。
✅意图驱动- 使用关键词和处理器定义自定义意图。
✅实时处理- 每条消息处理需5-10秒(首次模型加载后)。
✅可定制- 可添加天气、状态、命令或任何其他功能。
✅生产就绪- 基于Clawdbot实际使用经验构建。
常见用例
天气机器人
// User says: "What's the weather in Bangalore?"
// Response: "Current weather in Delhi is 19°C..."
// (Built-in intent, just enable it)
智能家居控制
// User says: "Turn on the lights"
// Handler: Sends signal to smart home API
// Response: "Lights turned on"
任务管理器
// User says: "Add milk to shopping list"
// Handler: Adds to database
// Response: "Added milk to your list"
状态检查器
// User says: "Is the system running?"
// Handler: Checks system status
// Response: "All systems online"
自定义
添加自定义意图
编辑voice-processor.js:
- 添加到 INTENTS 映射:
const INTENTS = {
'shopping': {
keywords: ['shopping', 'list', 'buy', 'खरीद'],
handler: 'handleShopping'
}
};
- 添加处理器:
const handlers = {
async handleShopping(language = 'en') {
return {
status: 'success',
response: language === 'en'
? "What would you like to add to your shopping list?"
: "आप अपनी शॉपिंग लिस्ट में क्या जोड़ना चाहते हैं?"
};
}
};
支持更多语言
- 更新
detectLanguage()针对您语言的 Unicode:
const urduChars = /[\u0600-\u06FF]/g; // Add this
- 在返回值中添加语言代码:
return language === 'ur' ? 'Urdu response' : 'English response';
- 在
transcribe.py中设置语言:
result = model.transcribe(data, language="ur")
更改转录模型
在transcribe.py中:
model = whisper.load_model("tiny") # Fastest, 39MB
model = whisper.load_model("base") # Default, 140MB
model = whisper.load_model("small") # Better, 466MB
model = whisper.load_model("medium") # Good, 1.5GB
架构
脚本:
transcribe.py- Whisper 转录(Python)voice-processor.js- 核心逻辑(意图解析,处理器)voice-listener-daemon.js- 自动监听器,监控新消息
参考资料:
SETUP.md- 安装与配置API.md- 详细的函数文档
与Clawdbot集成
如果作为Clawdbot技能运行,请接入消息事件:
// In your Clawdbot handler
const { processVoiceNote } = require('skills/whatsapp-voice-talk/scripts/voice-processor');
message.on('voice', async (audioBuffer) => {
const result = await processVoiceNote(audioBuffer, message.from);
// Send response back
await message.reply(result.response);
// Or send as voice (requires TTS)
await sendVoiceMessage(result.response);
});
性能
- 首次运行:约30秒(下载Whisper模型,约140MB)
- 典型情况:每条消息5-10秒
- 内存:约1.5GB(基础模型)
- 语言:英语、印地语(可轻松扩展)
支持的音频格式
OGG (Opus)、WAV、FLAC、MP3、CAF、AIFF,以及通过libsndfile支持的其他格式。
WhatsApp默认使用Opus编码的OGG格式——开箱即用。
故障排除
“No module named 'whisper'”
pip install openai-whisper
“No module named 'soundfile'”
pip install soundfile
语音消息无法处理?
- 检查:
clawdbot status(它是否在运行?) - 检查:
~/.clawdbot/media/inbound/(文件是否已到达?) - 手动运行守护进程:
node scripts/voice-listener-daemon.js(查看日志)
转录速度慢?使用更小的模型:whisper.load_model("base")或"tiny"
延伸阅读
- 设置指南:请参阅
references/SETUP.md获取详细的安装和配置说明 - API 参考:请参阅
references/API.md获取函数签名和示例 - 示例:检查
脚本/用于工作代码
许可证
MIT - 自由使用、自定义、贡献回馈!
专为Clawdbot的实际应用场景构建。经过多语言和多场景的实战测试。
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~