[Bug] 微信端gewechat上转发语音报错
发生了什么
在微信端gewechat上做语音转发的时候,用data/temp中缓存的语音文件voice_path生成Record的消息链,然后调用self.context.send_message(session, message_chain) 报错:wave.Error: file does not start with RIFF id。 是目前不支持gewechat端的发送语音文件还是我使用方式有问题?
`
获取缓存的语音文件
lif msg_type == 34: for item in event.get_messages(): if isinstance(item, Record): voice_path=item.file
生成包含Record的消息链
from astrbot.api.message_components import Plain, Image, Record message_segments = [Record(file=voice_path, url=voice_path)]
from astrbot.api.event import MessageChain message_chain = MessageChain(message_segments)
发送到之前记录的session
await self.context.send_message(session, message_chain) `
如何复现?
安装项目所需的pilk库之后,按上述代码发送语音
AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
AstrBot 版本: v3.4.39 部署方式:mac m2 使用的消息平台适配器:gewechat
操作系统
macOS
报错日志
[10:00:11] [Core] [ERRO] [gewechat.gewechat_event:94]: Traceback (most recent call last): File "/Users/liyang/docker/AstrBot/astrbot/core/platform/sources/gewechat/gewechat_event.py", line 92, in send_with_client duration = await wav_to_tencent_silk(record_path, silk_path) File "/Users/liyang/docker/AstrBot/astrbot/core/utils/tencent_record_helper.py", line 49, in wav_to_tencent_silk with wave.open(wav_path, "rb") as wav: File "/Users/liyang/.pyenv/versions/3.10.0/lib/python3.10/wave.py", line 509, in open return Wave_read(f) File "/Users/liyang/.pyenv/versions/3.10.0/lib/python3.10/wave.py", line 163, in init self.initfp(f) File "/Users/liyang/.pyenv/versions/3.10.0/lib/python3.10/wave.py", line 130, in initfp raise Error('file does not start with RIFF id') wave.Error: file does not start with RIFF id
你愿意提交 PR 吗?
- [x] 是的,我愿意提交 PR!
Code of Conduct
- [x] 我已阅读并同意遵守该项目的 行为准则。
翻了下源码,在发送语音文件时,AstrBot将文件按照WAV格式格式打开然后转换为silk格式。在直接用AstrBot Core 缓存的silk文件发送时,就会出错。 希望owner能兼容一下
Closed as upstream service is unavailable. #1443