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

无法发送语音文件 #517

Open
lingdu2333 opened this issue Dec 14, 2024 · 3 comments
Open

无法发送语音文件 #517

lingdu2333 opened this issue Dec 14, 2024 · 3 comments

Comments

@lingdu2333
Copy link

RT,目前gsk似乎无法发送语音 无论是mp3/silk均无法发送
nonebot 代码如下:

try:
            with open(silk_audio_path, "rb") as f:
                silk_base64 = base64.b64encode(f.read()).decode("utf-8")
        except Exception as e:
            logger.error(f"Failed to encode silk audio to base64: {e}")
            await guess_music_start.finish("音频编码失败,请稍后再试", reply_message=True)

    # 发送音频文件,使用 base64
        await guess_music_start.send(MessageSegment.record(f"base64://{silk_base64}"))

gsk报错日志:

2024/12/14 17:12:49 INFO: [ws][ID:***][Shard:(0/1)][Intent:***] receive Event message, {"op":0,"s":2,"t":"GROUP_AT_MESSAGE_CREATE","id":"GROUP_AT_MESSAGE_CREATE:***","d":{"author":{"id":"***","member_openid":"***","union_openid":"***"},"content":" 猜歌","group_id":"***","group_openid":"***","id":"***","message_scene":{"callback_data":"","source":"default"},"timestamp":"2024-12-14T17:13:47+08:00"}}
2024/12/14 17:12:49 RawMessage: 猜歌
2024/12/14 17:12:49 MessageID: ***
2024/12/14 17:12:49 GroupID: ***
2024/12/14 17:12:49 MessageType: group
2024/12/14 17:12:49 PostType: message
2024/12/14 17:12:49 SelfID: ***
2024/12/14 17:12:49 Sender: {  376785802 member  0 0 0 0 }
2024/12/14 17:12:49 SubType: normal
2024/12/14 17:12:49 Time: 1734167569
2024/12/14 17:12:49 Avatar:
2024/12/14 17:12:49 Echo:
2024/12/14 17:12:49 Message: [map[data:map[text:猜歌] type:text]]
2024/12/14 17:12:49 MessageSeq: 0
2024/12/14 17:12:49 Font: 0
2024/12/14 17:12:49 UserID: ***
2024/12/14 17:12:49 RealMessageType:
2024/12/14 17:12:49 RealUserID:
2024/12/14 17:12:49 RealGroupID:
2024/12/14 17:12:49 IsBindedGroupId: false
2024/12/14 17:12:49 IsBindedUserId: false
2024/12/14 17:12:51 Received from onebotv11 server: Action: send_msg, Params: {"channel_id":"","guild_id":"","group_id":"83278180","message_id":"","message":[{"data":{"cache":null,"file":"*** Echo: 90
2024/12/14 17:12:51 send_group_msg获取到信息类型:group
2024/12/14 17:12:51 params.message is a slice (segment_type_koishi)
2024/12/14 17:12:51 echo取群组发信息对应的message_id:
2024/12/14 17:12:51 群组发信息messageText:
2024/12/14 17:12:51 GetMessageIDByUseridAndGroupid_key:***
2024/12/14 17:12:51 通过GetMessageIDByUseridAndGroupid函数获取的message_id: ***
2024/12/14 17:12:51 群组发信息使用messageID:[ROBOT1.0_***]
2024/12/14 17:12:51 sampleRate24000
2024/12/14 17:12:51 bitRate24000
2024/12/14 17:12:51 音频转码ing
2024/12/14 17:12:51 INFO: [OPENAPI]POST https://sandbox.api.sgroup.qq.com/v2/groups/FCC5CD29A025173A15D9FB0495CCD16F/files, traceID:feccc405d148281d4cc1b60caabf8398, status:400 Bad Request, elapsed:95.773872ms req: {"file_type":1,"file_data":"**此处data我已删除**"}, resp: {"message":"富媒体文件格式不支持","code":850019,"err_code":40034002,"trace_id":"feccc405d148281d4cc1b60caabf8398"}
2024/12/14 17:12:51 Error messageToCreate: code:400, text:{"message":"富媒体文件格式不支持","code":850019,"err_code":40034002,"trace_id":"feccc405d148281d4cc1b60caabf8398"}, traceID:feccc405d148281d4cc1b60caabf8398
2024/12/14 17:12:51 Error: Expected RichMediaMessage type for key base64_record.

不清楚是不是由于错误判断 导致file_type一直为1 但应该为3?
image

本人尝试过 通过直接传入绝对路径/base64 均无法使用 都会报错上传语音失败

@lingdu2333
Copy link
Author

nonebot未见明显异常 未有报错 所以可能问题出现在gsk上面
发送的测试音频可以正常打开 使用gsk Release 513/merge

@lingdu2333
Copy link
Author

9cf625f3a8a254643dda0fe1cafeb469
查看了一下 send_group_msg 类 似乎是这里意外的file_type设置为了1 导致的错误

@lingdu2333
Copy link
Author

已提pr(#518 ) 将type设置正确皆可发送语音文件
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant