参数默认值说明lang``en语言: en 或 zh``skipConfirmation``false是否跳过文字确认步骤speed``90%TTS 语速( --rate=-10% = 90%)voice``en-US-EmmaNeural(英文)/ zh-CN-XiaoxiaoNeural(中文)TTS 声音splitSentences``false是否生成按句拆分的音频
语言OCR 语言包TTS Voiceen``eng(预装)en-US-EmmaNeural``zh``chi_sim(需安装)zh-CN-XiaoxiaoNeural
中文 OCR 语言包安装:
- Linux(WSL/Debian/Ubuntu):
apt-get install tesseract-ocr-chi-sim- macOS:
brew install tesseract-lang(自带中文)- Windows:下载
chi_sim.traineddata放入 Tesseract 安装目录的tessdata文件夹
lang 指定语言)text
图片 → OCR 提取文字 → 展示给用户确认 → 用户确认 → 生成 TTS → 发送
文字 → 直接生成 TTS → 发送
用户说"不需要确认"或"直接生成"时,跳过确认步骤。
⚠️ 安全提示:skipConfirmation 会跳过文字确认步骤,OCR 提取的文本(可能包含敏感信息)会直接转为音频并发送。适用于可信来源、低敏感内容。建议默认关闭(
skipConfirmation: false)。
python
# 图片预处理
from PIL import Image, ImageOps
img = Image.open(image_path)
img = ImageOps.autocontrast(img.convert('L'), cutoff=10)
w, h = img.size
img = img.resize((w*4, h*4), Image.LANCZOS)
img.save('/tmp/ocr_input.jpg', quality=99)
bash
# 英文
tesseract /tmp/ocr_input.jpg stdout -l eng --psm 4
# 中文
tesseract /tmp/ocr_input.jpg stdout -l chi_sim --psm 4
bash
uvx edge-tts \
-t "FULL TEXT" \
-v en-US-EmmaNeural \
--rate=-10% \
--write-media OUTPUT_DIR/full_article.mp3
# 中文
uvx edge-tts \
-t "中文文字内容" \
-v zh-CN-XiaoxiaoNeural \
--rate=-10% \
--write-media OUTPUT_DIR/full_article.mp3
python
import subprocess, re
def split_sentences(text, lang='en'):
if lang == 'zh':
# 中文按句号/感叹号/问号拆分
sentences = re.split(r'(?<=[。!?])\s*', text)
else:
# 英文按 .!? 拆分
sentences = re.split(r'(?<=[.!?])\s+', text)
return [s.strip() for s in sentences if s.strip()]
sentences = split_sentences(text, lang=lang)
for i, sentence in enumerate(sentences, 1):
num = str(i).zfill(2)
voice = 'zh-CN-XiaoxiaoNeural' if lang == 'zh' else 'en-US-EmmaNeural'
subprocess.run([
"uvx", "edge-tts",
"-t", sentence,
"-v", voice,
"--rate=-10%",
"--write-media", f"OUTPUT_DIR/sentence_{num}.mp3"
])
text
/mnt/d/wslspace/workspace/articles/YYYY-MM-DD-article-slug/
├── original_text.md
├── full_article.mp3
└── sentence_01.mp3 ...
The agent detects the active channel from the runtime context and calls message(...) accordingly. No hardcoded channel — the agent uses whichever channel the user is currently chatting through.
python
# Detect active channel automatically (from runtime inbound metadata)
# channel is inferred: feishu / telegram / discord / whatsapp / signal / imessage / openclaw-weixin
# 发送全文
message(action="send", channel="{active_channel}",
message="📄 全文音频",
media="PATH/full_article.mp3",
filename="full_article.mp3")
# 发送每句
for i, sentence in enumerate(sentences, 1):
num = str(i).zfill(2)
message(action="send", channel="{active_channel}",
message=f"📝 {num}: {sentence}",
media=f"PATH/sentence_{num}.mp3",
filename=f"sentence_{num}.mp3")
Channel音频支持备注Feishu✅推荐使用 feishu-voice-send skill 发送语音消息Telegram✅直接发送 mp3Discord✅作为附件发送WhatsApp✅直接发送 mp3Signal⚠️取决于信号强度,可能不支持iMessage⚠️通过 macOS 发送,mp3 兼容性一般WeChat Work✅同 Feishu
If the channel does not support audio, the agent saves the file to OUTPUT_DIR and sends the file path as a text message instead.
重要说明: OpenClaw 内置的飞书媒体发送存在 bug(缺少 duration 参数),导致 .ogg 文件有时显示为附件而非语音消息。
推荐方案:使用 feishu-voice-send skill
该 skill 调用飞书官方 API,正确传递 duration 参数,确保语音消息正常显示。
bash
# 发送现有的 .ogg 文件
python3 /mnt/d/wslspace/workspace/skills/feishu-voice-send/scripts/send_voice.py \
/path/to/audio.ogg \
<接收者open_id>
# 或直接生成 TTS 并发送
python3 /mnt/d/wslspace/workspace/skills/feishu-voice-send/scripts/tts_and_send.py \
"要转换的文字" \
<接收者open_id> \
-v zh-CN-YunjianNeural \
-r -10%
如果必须使用 OpenClaw 内置的 message 工具,需要:
bash
# 1. 用 edge-tts 生成 mp3
uvx edge-tts \
-t "Your text here" \
-v en-US-EmmaNeural \
--rate=-10% \
--write-media OUTPUT_DIR/voice.mp3
# 2. 用 ffmpeg 转换为标准 Ogg Opus
ffmpeg -i OUTPUT_DIR/voice.mp3 \
-c:a libopus \
-b:a 32k \
-ar 24000 \
-ac 1 \
OUTPUT_DIR/voice.ogg
# 3. 使用 message 工具发送(仍可能显示为附件)
message(action="send", channel="feishu", \
message="📄 语音", \
media="OUTPUT_DIR/voice.ogg")
en-US-EmmaNeural, en-US-BrianNeural, en-GB-LibbyNeural, ...
zh-CN-XiaoxiaoNeural(女声), zh-CN-YunxiNeural(男声), zh-CN-YunyangNeural(新闻男声), ...
查看完整列表: uvx edge-tts -l | grep "zh-CN"
apt-get install tesseract-ocr-chi-simuvx 运行,无需安装