Voice Message
Send text as voice messages to any chat channel.
Prerequisites
- -
edge-tts — Microsoft Edge TTS (pip install edge-tts) - INLINECODE2 /
ffprobe — audio conversion and duration detection
Default Voices
Step 1: Generate Voice File
Use scripts/gen_voice.sh to convert text to an ogg/opus file:
CODEBLOCK0
Arguments: <text> <output.ogg> [voice]
- - If voice is omitted, defaults to
zh-CN-XiaoxiaoNeural.
Step 2: Send by Channel
Generic (Telegram, Signal, WhatsApp, etc.)
Use the message tool directly:
CODEBLOCK1
This works for most channels. Telegram confirmed working.
Feishu/Lark
⚠️ Feishu does NOT support asVoice=true via the message tool. You must use the dedicated script.
Use scripts/send_feishu_voice.sh:
CODEBLOCK2
- -
receive_id_type: open_id (default), chat_id, user_id, union_id, INLINECODE16 - The script handles upload (as opus with duration) and sends as audio message type to produce a voice bubble.
- To get
tenant_access_token, use the Feishu tenant token API with your app credentials.
Discord
Discord voice messages require a waveform and special flags.
- 1. Generate ogg with INLINECODE18
- Generate waveform: INLINECODE19
- Outputs JSON:
{"duration_secs": 4.2, "waveform": "base64..."}
- 3. Send via Discord API with
flags: 8192 (ISVOICEMESSAGE) and the waveform/duration in attachments metadata.
- Missing waveform/duration causes error 50161.
Fallback
If asVoice=true does not produce a voice bubble on a channel:
- 1. Try sending via the platform's native API
- If native API unavailable, send as audio file attachment
语音消息
将文本以语音消息的形式发送到任何聊天频道。
前置条件
- - edge-tts — Microsoft Edge TTS(pip install edge-tts)
- ffmpeg / ffprobe — 音频转换与时长检测
默认语音
第一步:生成语音文件
使用 scripts/gen_voice.sh 将文本转换为 ogg/opus 格式文件:
bash
scripts/gen_voice.sh 你好 /tmp/voice.ogg
scripts/gen_voice.sh Hello /tmp/voice.ogg en-US-JennyNeural
参数:<文本> <输出文件.ogg> [语音]
- - 若省略语音参数,默认使用 zh-CN-XiaoxiaoNeural。
第二步:按频道发送
通用频道(Telegram、Signal、WhatsApp 等)
直接使用消息工具:
action=send, asVoice=true, filePath=/tmp/voice.ogg
此方法适用于大多数频道。Telegram 已验证可用。
飞书/ Lark
⚠️ 飞书不支持通过消息工具使用 asVoice=true。必须使用专用脚本。
使用 scripts/sendfeishuvoice.sh:
bash
scripts/sendfeishuvoice.sh /tmp/voice.ogg <接收者ID> <租户访问令牌> [接收者ID类型]
- - receiveidtype:openid(默认)、chatid、userid、unionid、email
- 该脚本负责上传(以包含时长的 opus 格式)并以音频消息类型发送,从而生成语音气泡。
- 如需获取 tenantaccesstoken,请使用飞书租户令牌 API 并提供应用凭证。
Discord
Discord 语音消息需要波形图和特殊标志。
- 1. 使用 scripts/genvoice.sh 生成 ogg 文件
- 生成波形图:python3 scripts/genwaveform.py /tmp/voice.ogg
- 输出 JSON:{duration_secs: 4.2, waveform: base64...}
- 3. 通过 Discord API 发送,设置 flags: 8192(ISVOICEMESSAGE),并在附件元数据中包含波形图/时长。
- 缺少波形图/时长会导致错误 50161。
备用方案
如果在某个频道上 asVoice=true 无法生成语音气泡:
- 1. 尝试通过该平台的原生 API 发送
- 若原生 API 不可用,则以音频文件附件形式发送