Install
openclaw skills install web-tts-speaker网页一键朗读:URL/文本 → TTS语音 → 多渠道自动匹配(飞书语音条 / 微信/TG/Discord MP3)
openclaw skills install web-tts-speaker网页/文字 → TTS语音 → 自动匹配来源渠道发送
当用户希望朗读网页或将文字转为语音时,按以下流程操作。
"朗读 https://abc.com/article" → URL
"读一下:你好世界" → 文本
直接发 URL → URL
从 inbound context 的 channel 字段获取:
| 值 | 来源 |
|---|---|
openclaw-weixin | 微信 |
feishu | 飞书 |
telegram | Telegram |
discord | Discord |
⚠️ 安全规则:
http:// 或 https:// 开头# ✅ 安全:argv 数组传参,不走 shell 解析
TOOL_DIR = r"C:\Users\www\.openclaw\workspace\skills\web-tts-speaker"
# 朗读网页
result = exec(
command=["python", "cli.py", "--url", url],
workdir=TOOL_DIR,
timeout=300
)
# 文字转语音
result = exec(
command=["python", "cli.py", "--text", text],
workdir=TOOL_DIR,
timeout=300
)
注意:
workdir参数指定工作目录,执行时自动切换到该目录。
CLI 一次性输出全部渠道标记。根据来源渠道选取对应的:
| 来源 channel | 取用标记 | 发送文件 |
|---|---|---|
openclaw-weixin | [WECHAT_VOICE] | file=xxx.mp3 |
feishu | [FEISHU_VOICE] | file=xxx.opus |
telegram | [TELEGRAM_VOICE] | file=xxx.mp3 |
discord | [DISCORD_VOICE] | file=xxx.mp3 |
# 微信
message(action="send", channel="openclaw-weixin", media=file_path)
# 飞书语音条
message(action="send", channel="feishu", asVoice=true, filePath=file_path)
# Telegram / Discord
message(action="send", channel="telegram", media=file_path)
# 用户说:朗读 https://zshttp.com/2981.html
# Step 2
channel = "openclaw-weixin" # 从 inbound context 获取
# Step 3 - 安全调用
import re
if not re.match(r"^https?://", url):
return "仅支持 http/https 链接"
result = exec(
command=["python", "cli.py", "--url", url],
workdir=r"C:\Users\www\.openclaw\workspace\skills\web-tts-speaker",
timeout=300
)
# Step 4 - 解析标记
for line in result.stdout.split("\n"):
if line.startswith("[WECHAT_VOICE]"):
# 取下几行找到 file=xxx
...
# Step 5 - 发送
message(action="send", channel=channel, media=file_path)
# 自动模式(推荐):生成全部格式
python cli.py --url https://example.com/article
python cli.py --text "你好世界"
# 指定单渠道
python cli.py --channel feishu --text "你好"
python cli.py -c wechat --text "你好"
| 渠道 | 格式 | 发送方式 |
|---|---|---|
| feishu | .opus (16kHz) | asVoice=true |
.mp3 (24kHz) | media=xxx | |
| telegram | .mp3 (24kHz) | media=xxx |
| discord | .mp3 (24kHz) | media=xxx |
⚠️ 微信说明:
openclaw-weixin插件暂未实现原生语音气泡发送(GH#61031),当前以 MP3 文件形式发送。
自动分块 + 拼接,不限长度。输出进度:
[1/2] 生成语音 (2772 字符)... 9分18秒
[2/2] 生成语音 (1543 字符)... 5分19秒
✅ 合成完成
📁 wechat: voice.mp3 (5140KB, 14分37秒)
python cli.py --text "你好" --voice zh-CN-YunxiNeural
zh-CN-XiaoxiaoNeural — 晓晓(女声,默认)zh-CN-YunxiNeural — 云希(男声,活泼)zh-CN-YunyangNeural — 云扬(男声,新闻)zh-CN-XiaoyiNeural — 晓伊(女声,柔和)[WECHAT_VOICE]
channel=wechat
file=/path/to/voice.mp3
text=新闻摘要...
dur=877
size=5262860
full=微信文件消息
[/WECHAT_VOICE]
pip install -r requirements.txt
依赖锁定的精确版本(ClawScan 推荐):
edge-tts==7.2.8beautifulsoup4==4.14.3requests==2.33.1额外依赖:FFmpeg(系统级)。