Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] 微信端gewechat上转发语音报错 #911

Open
2 tasks done
NiceAir opened this issue Mar 21, 2025 · 1 comment
Open
2 tasks done

[Bug] 微信端gewechat上转发语音报错 #911

NiceAir opened this issue Mar 21, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@NiceAir
Copy link

NiceAir commented Mar 21, 2025

发生了什么

在微信端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 吗?

  • 是的,我愿意提交 PR!

Code of Conduct

@NiceAir NiceAir added the bug Something isn't working label Mar 21, 2025
@NiceAir
Copy link
Author

NiceAir commented Mar 21, 2025

翻了下源码,在发送语音文件时,AstrBot将文件按照WAV格式格式打开然后转换为silk格式。在直接用AstrBot Core 缓存的silk文件发送时,就会出错。 希望owner能兼容一下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant