Install
openclaw skills install @shuaishi1991/openclaw-feishu-voice-freeOpenClaw 飞书语音聊天技能,基于本地 Qwen3-TTS 和 Whisper,实现离线多语言语音识别与合成,无需云端API。
openclaw skills install @shuaishi1991/openclaw-feishu-voice-free一个为 OpenClaw + 飞书客户端设计的全语音对话技能,基于 Qwen3-TTS 和 Whisper 实现完全离线的语音识别和语音合成。无需任何云端 API,所有模型本地运行。
git clone https://github.com/shuaishi1991/openclaw-feishu-voice-free.git
cd openclaw-feishu-voice-free
按照 安装 部分的详细步骤进行:
bash setup.sh)编辑 /root/.openclaw/openclaw.json,按照 配置 部分的说明添加配置。
cd /root/.openclaw/skills/openclaw-feishu-voice-free
source venv/bin/activate
# 启动 Whisper ASR 服务(端口 8001)
nohup python scripts/server/whisper-server.py --port 8001 > /tmp/whisper-server.log 2>&1 &
# 启动 Qwen3-TTS 服务(端口 8000,使用 OpenAI 兼容 API)
nohup python scripts/server/tts-base-server-openai.py --port 8000 --clone voice_embedings/huopo_kexin.pt > /tmp/tts-server.log 2>&1 &
deactivate
注意: 如果还没有音色文件,可以先不指定 --clone 参数,使用默认音色。后续可以通过 音色克隆工具 创建自定义音色。
openclaw gateway restart
现在你可以在飞书发送语音消息,系统会自动识别并回复语音!
详细说明: 如需了解更多信息,请查看 安装、配置 和 使用方法 部分。
openclaw-feishu-voice-free/
├── README.md # 项目说明文档
├── setup.sh # 虚拟环境安装脚本
├── openclaw.json # 配置文件示例
├── voice_embedings/ # 存放克隆好的音色文件(.pt 格式)
└── scripts/
├── server/
│ ├── whisper-server.py # Whisper ASR HTTP 服务(端口 8001)
│ ├── tts-base-server.py # Qwen3-TTS HTTP 服务(自定义 API)
│ └── tts-base-server-openai.py # Qwen3-TTS HTTP 服务(OpenAI 兼容 API,推荐)
└── tools/
└── tts-base.py # 音色克隆工具(独立测试和克隆音色)
需要下载以下模型到本地:
| 模型 | HuggingFace Repo | 默认路径 | 大小 |
|---|---|---|---|
| Whisper ASR | openai/whisper-large-v3-turbo | /root/.openclaw/models/whisper/whisper-large-v3-turbo | ~3GB |
| Qwen3-TTS | Qwen/Qwen3-TTS-12Hz-1.7B-Base | /root/.openclaw/models/Qwen3-TTS/Qwen3-TTS-12Hz-1.7B-Base | ~3.5GB |
mkdir -p /root/.openclaw/skills/openclaw-feishu-voice-free
cp -r * /root/.openclaw/skills/openclaw-feishu-voice-free/
chmod +x /root/.openclaw/skills/openclaw-feishu-voice-free/setup.sh
cd /root/.openclaw/skills/openclaw-feishu-voice-free
bash setup.sh
setup.sh 会自动:
需要下载两个模型到本地:
# 创建模型目录
mkdir -p /root/.openclaw/models/whisper
# 使用 huggingface-cli 下载(推荐)
pip install huggingface_hub
huggingface-cli download openai/whisper-large-v3-turbo \
--local-dir /root/.openclaw/models/whisper/whisper-large-v3-turbo \
--local-dir-use-symlinks False
# 或者使用 Python 脚本下载
python -c "
from huggingface_hub import snapshot_download
snapshot_download(
repo_id='openai/whisper-large-v3-turbo',
local_dir='/root/.openclaw/models/whisper/whisper-large-v3-turbo',
local_dir_use_symlinks=False
)
"
# 创建模型目录
mkdir -p /root/.openclaw/models/Qwen3-TTS
# 使用 huggingface-cli 下载(推荐)
huggingface-cli download Qwen/Qwen3-TTS-12Hz-1.7B-Base \
--local-dir /root/.openclaw/models/Qwen3-TTS/Qwen3-TTS-12Hz-1.7B-Base \
--local-dir-use-symlinks False
# 或者使用 Python 脚本下载
python -c "
from huggingface_hub import snapshot_download
snapshot_download(
repo_id='Qwen/Qwen3-TTS-12Hz-1.7B-Base',
local_dir='/root/.openclaw/models/Qwen3-TTS/Qwen3-TTS-12Hz-1.7B-Base',
local_dir_use_symlinks=False
)
"
注意:
# Ubuntu/Debian
apt install ffmpeg
# CentOS/RHEL
yum install ffmpeg
在 /root/.openclaw/openclaw.json 中配置:
在 tools.media.audio 中配置 Whisper 服务:
{
"tools": {
"media": {
"audio": {
"enabled": true,
"models": [
{
"type": "cli",
"command": "bash",
"args": [
"-c",
"curl -s -X POST http://localhost:8001/transcribe -H 'Content-Type: application/json' -d \"{\\\"audio_path\\\": \\\"{{MediaPath}}\\\", \\\"language\\\": \\\"Chinese\\\"}\" | jq -r '.text // empty'"
],
"timeoutSeconds": 60
}
]
}
}
}
}
在 messages.tts 中配置 TTS 服务(使用 OpenAI 兼容 API):
{
"messages": {
"tts": {
"auto": "always",
"provider": "openai",
"timeoutMs": 120000,
"openai": {
"apiKey": "no need",
"baseUrl": "http://localhost:8000/v1",
"model": "Qwen3-TTS-12Hz-1.7B-Base",
"voice": "huopo_kexin"
}
}
}
}
注意:
baseUrl 指向本地 TTS 服务(使用 tts-base-server-openai.py)voice 参数会被忽略(实际使用启动服务时指定的 --clone 音色文件)apiKey 可以设置为任意值(本地服务不需要)cd /root/.openclaw/skills/openclaw-feishu-voice-free
source venv/bin/activate
python scripts/server/whisper-server.py \
--port 8001 \
--model /root/.openclaw/models/whisper/whisper-large-v3-turbo \
--language Chinese
参数说明:
--port: 服务端口(默认 8001)--model: 模型路径或 HuggingFace repo ID(默认 openai/whisper-large-v3-turbo)--language: 默认识别语言(默认 Chinese)--batch-size: 批处理大小(默认 16)模型说明:
openai/whisper-large-v3-turbo 模型openai/whisper-large-v3、openai/whisper-medium 等cd /root/.openclaw/skills/openclaw-feishu-voice-free
source venv/bin/activate
python scripts/server/tts-base-server-openai.py \
--port 8000 \
--model /root/.openclaw/models/Qwen3-TTS/Qwen3-TTS-12Hz-1.7B-Base \
--clone voice_embedings/huopo_kexin.pt
参数说明:
--port: 服务端口(默认 8000)--model: 模型路径或 HuggingFace repo ID(默认 Qwen/Qwen3-TTS-12Hz-1.7B-Base)--clone: 音色克隆文件路径(可选,支持相对路径)音色文件路径:
/path/to/voice.ptvoice_embedings/my_voice.pt(会自动在 skill 目录和 voice_embedings 目录查找)API 端点:
POST /v1/audio/speech - 生成语音(兼容 OpenAI TTS API)GET /v1/models - 获取模型列表GET / - 健康检查如果需要使用自定义 API 格式,可以使用 tts-base-server.py:
cd /root/.openclaw/skills/openclaw-feishu-voice-free
source venv/bin/activate
python scripts/server/tts-base-server.py \
--port 8000 \
--model /root/.openclaw/models/Qwen3-TTS/Qwen3-TTS-12Hz-1.7B-Base \
--clone voice_embedings/my_voice.pt
API 端点:
POST /generate - 生成语音GET / - 健康检查使用 scripts/tools/tts-base.py 工具可以克隆任意人声并生成音色文件:
cd /root/.openclaw/skills/openclaw-feishu-voice-free
source venv/bin/activate
# 从参考音频克隆音色并保存为 .pt 文件
python scripts/tools/tts-base.py \
--audio /path/to/reference_audio.wav \
--text "这是参考音频的文字内容" \
--save-clone voice_embedings/my_custom_voice.pt \
--prompt "测试生成的语音"
# 使用已保存的音色文件生成语音
python scripts/tools/tts-base.py \
--clone voice_embedings/my_custom_voice.pt \
--prompt "使用克隆音色生成的文本" \
--output output.wav
deactivate
音色克隆说明:
--audio: 参考音频文件路径(支持 wav、mp3、m4a 格式)--text: 参考音频的文字内容(必须准确)--save-clone: 保存克隆音色到指定路径(.pt 格式)--clone: 使用已保存的音色文件生成语音voice_embedings/ 目录下cd /root/.openclaw/skills/openclaw-feishu-voice-free
source venv/bin/activate
# 启动 Whisper ASR 服务(端口 8001)
nohup python scripts/server/whisper-server.py --port 8001 > /tmp/whisper-server.log 2>&1 &
# 启动 Qwen3-TTS 服务(端口 8000,OpenAI 兼容 API)
nohup python scripts/server/tts-base-server-openai.py --port 8000 --clone voice_embedings/huopo_kexin.pt > /tmp/tts-server.log 2>&1 &
deactivate
# 检查 Whisper 服务
curl http://localhost:8001/
# 检查 TTS 服务
curl http://localhost:8000/
openclaw gateway restart
系统会自动:
# 使用 curl 测试 Whisper 服务
curl -X POST http://localhost:8001/transcribe \
-H "Content-Type: application/json" \
-d '{"audio_path": "/path/to/audio.mp3", "language": "Chinese"}'
# 使用 curl 测试 TTS 服务(OpenAI 兼容 API)
curl -X POST http://localhost:8000/v1/audio/speech \
-H "Content-Type: application/json" \
-d '{
"model": "Qwen3-TTS-12Hz-1.7B-Base",
"input": "你好,欢迎使用 Qwen3-TTS",
"voice": "alloy"
}' \
--output output.mp3
创建 systemd 服务文件可以确保服务在系统重启后自动启动:
创建 /etc/systemd/system/openclaw-feishu-voice-free-whisper.service:
[Unit]
Description=OpenClaw Feishu Voice Free Whisper ASR Server
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/.openclaw/skills/openclaw-feishu-voice-free
Environment="PATH=/root/.openclaw/skills/openclaw-feishu-voice-free/venv/bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=/root/.openclaw/skills/openclaw-feishu-voice-free/venv/bin/python scripts/server/whisper-server.py --port 8001
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
创建 /etc/systemd/system/openclaw-feishu-voice-free-tts.service:
[Unit]
Description=OpenClaw Feishu Voice Free Qwen3-TTS Server (OpenAI Compatible)
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/root/.openclaw/skills/openclaw-feishu-voice-free
Environment="PATH=/root/.openclaw/skills/openclaw-feishu-voice-free/venv/bin:/usr/local/bin:/usr/bin:/bin"
ExecStart=/root/.openclaw/skills/openclaw-feishu-voice-free/venv/bin/python scripts/server/tts-base-server-openai.py --port 8000 --clone voice_embedings/huopo_kexin.pt
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable openclaw-feishu-voice-free-whisper openclaw-feishu-voice-free-tts
sudo systemctl start openclaw-feishu-voice-free-whisper openclaw-feishu-voice-free-tts
sudo systemctl status openclaw-feishu-voice-free-whisper openclaw-feishu-voice-free-tts
1. 用户在飞书发送语音消息
↓
2. OpenClaw 接收并下载音频文件到本地
↓
3. OpenClaw 通过 tools.media.audio 配置调用 Whisper 服务(HTTP API)
POST http://localhost:8001/transcribe
↓
4. Whisper 服务识别语音为文字,返回给 OpenClaw
↓
5. OpenClaw 调用 LLM(如 GPT、Claude 等)生成文字回复
↓
6. OpenClaw 通过 messages.tts 配置调用 TTS 服务(OpenAI 兼容 API)
POST http://localhost:8000/v1/audio/speech
↓
7. TTS 服务合成语音(自动清理括号内容和表情符号),返回 MP3 文件
↓
8. OpenClaw 发送语音消息给飞书用户
TTS 服务会自动清理 LLM 回复中的括号描述内容和表情符号,不会朗读:
输入: "(嘴角微笑) 今天天气真好😊 (看向窗外)"
输出: "今天天气真好"
清理规则:
(xxx)[xxx]{xxx}torch - PyTorch 深度学习框架transformers - HuggingFace transformers(用于 Whisper)accelerate - 模型加速soundfile - 音频文件处理requests - HTTP 请求qwen-tts - Qwen3-TTS 模型pydub - 音频格式转换所有依赖会在运行 setup.sh 时自动安装。
ffmpeg - 音频处理(可选,推荐安装)A: 确保系统有 Python 3.10-3.12。检查版本:
python3 --version
如果不是 3.10-3.12,需要安装正确版本。
A: 检查以下几点:
netstat -tulpn | grep -E "(8000|8001)"
source venv/bin/activate
pip list | grep -E "(torch|transformers|qwen-tts)"
tail -f /tmp/whisper-server.log
tail -f /tmp/tts-server.log
A: 检查配置和日志:
cat /root/.openclaw/openclaw.json | grep -A 20 "openclaw-feishu-voice-free"
openclaw skill list | grep openclaw-feishu-voice-free
tail -f /root/.openclaw/logs/openclaw.log
A: 确保:
messages.tts.auto: "always" 已设置messages.tts.provider: "openai" 已设置(使用 OpenAI 兼容 API)messages.tts.openai.baseUrl: "http://localhost:8000/v1" 已设置curl http://localhost:8000/tail -f /tmp/tts-server.logA: 有两种方式:
cd /root/.openclaw/skills/openclaw-feishu-voice-free
source venv/bin/activate
# 从参考音频克隆音色并保存
python scripts/tools/tts-base.py \
--audio /path/to/reference_audio.wav \
--text "参考音频的文字内容" \
--save-clone voice_embedings/my_voice.pt \
--prompt "测试文本"
deactivate
# 使用绝对路径
python scripts/server/tts-base-server-openai.py --clone /path/to/your-voice.pt
# 或使用相对路径(从 skill 目录或 voice_embedings 目录)
python scripts/server/tts-base-server-openai.py --clone voice_embedings/my_voice.pt
注意:
.pt 格式,使用 scripts/tools/tts-base.py 的 --save-clone 参数生成--clone 参数A: 检查以下几点:
# 检查端口占用
netstat -tulpn | grep -E "(8000|8001)"
# 检查进程
ps aux | grep -E "(whisper-server|tts-base-server)"
tail -f /tmp/whisper-server.log
tail -f /tmp/tts-server.log
# 如果服务绑定在 0.0.0.0,确保防火墙允许端口
# Ubuntu/Debian
ufw allow 8000
ufw allow 8001
# 检查 Whisper 模型
ls -lh /root/.openclaw/models/whisper/whisper-large-v3-turbo/
# 检查 Qwen3-TTS 模型
ls -lh /root/.openclaw/models/Qwen3-TTS/Qwen3-TTS-12Hz-1.7B-Base/
A: 检查以下几点:
# 检查 voice_embedings 目录
ls -la /root/.openclaw/skills/openclaw-feishu-voice-free/voice_embedings/
如果相对路径不工作,使用绝对路径:
python scripts/server/tts-base-server-openai.py --clone /root/.openclaw/skills/openclaw-feishu-voice-free/voice_embedings/huopo_kexin.pt
确保音色文件是 .pt 格式,并且是通过 tts-base.py --save-clone 生成的
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情。
Shuai Shi
如果这个项目对你有帮助,请给个 Star ⭐!
注意: 这是一个 OpenClaw Skill,需要先安装和配置 OpenClaw 才能使用。