MrXiaoM / Overflow

替换 mirai 实现为 Onebot 以进行无缝迁移
https://mirai.mrxiaom.top
GNU Affero General Public License v3.0
313 stars 25 forks source link

语音消息无法发送 #28

Open onlyzqy opened 6 months ago

onlyzqy commented 6 months ago

问题描述

通过overflow和lagrange发送语音消息无法发出

复现

通过overflow和lagrange发送语音消息无法发出

Overflow 版本

8c7dd0c

其他组件版本

No response

系统日志

2024-03-08 23:08:02 W/Onebot: Request failed: [send_group_msg, echo=196] app=Lagrange.OneBot v0.0.3 ,message=, retCode=200, retJson={"status":"failed","retcode":200,"data":null,"echo":196}
2024-03-08 23:08:02 V/Bot.2411510662: Group(937068620) <- [overflow:audio,file=base64:////lcQBTAAAD+M66iEFCEDHR0zPvlSVMi... (about 10.83 KB)]

网络日志

2024-03-08 23:08:02 D/Onebot: Client received <-- {"status":"failed","retcode":200,"data":null,"echo":196}
2024-03-08 23:08:02 W/Onebot: Request failed: [send_group_msg, echo=196] app=Lagrange.OneBot v0.0.3 ,message=, retCode=200, retJson={"status":"failed","retcode":200,"data":null,"echo":196}
2024-03-08 23:08:02 V/Onebot: Stacktrace: 
cn.evolvefield.onebot.client.util.ActionFailedException: app=Lagrange.OneBot v0.0.3 ,message=, retCode=200, retJson={"status":"failed","retcode":200,"data":null,"echo":196}
    at cn.evolvefield.onebot.client.util.ActionSendRequest.send(ActionSendRequest.kt:49)
    at cn.evolvefield.onebot.client.util.ActionSendRequest$send$1.invokeSuspend(ActionSendRequest.kt)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33)
    at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
    at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:178)
    at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166)
    at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420)
    at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:328)
    at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke(JobSupport.kt:1413)
    at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:318)
    at kotlinx.coroutines.JobSupport.tryFinalizeSimpleState(JobSupport.kt:295)
    at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:856)
    at kotlinx.coroutines.JobSupport.makeCompleting$kotlinx_coroutines_core(JobSupport.kt:806)
    at kotlinx.coroutines.CompletableDeferredImpl.complete(CompletableDeferred.kt:92)
    at cn.evolvefield.onebot.client.util.ActionSendRequest.onCallback(ActionSendRequest.kt:64)
    at cn.evolvefield.onebot.client.handler.ActionHandler.onReceiveActionResp(ActionHandler.kt:38)
    at cn.evolvefield.onebot.client.connection.IAdapter$DefaultImpls.onReceiveMessage(IAdapter.kt:26)
    at cn.evolvefield.onebot.client.connection.WSClient.onReceiveMessage(WSClient.kt:19)
    at cn.evolvefield.onebot.client.connection.WSClient.onMessage(WSClient.kt:45)
    at top.mrxiaom.overflow.internal.deps.websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:636)
    at top.mrxiaom.overflow.internal.deps.websocket.drafts.Draft_6455.processFrameText(Draft_6455.java:986)
    at top.mrxiaom.overflow.internal.deps.websocket.drafts.Draft_6455.processFrame(Draft_6455.java:910)
    at top.mrxiaom.overflow.internal.deps.websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:402)
    at top.mrxiaom.overflow.internal.deps.websocket.WebSocketImpl.decode(WebSocketImpl.java:234)
    at top.mrxiaom.overflow.internal.deps.websocket.client.WebSocketClient.run(WebSocketClient.java:516)
    at java.base/java.lang.Thread.run(Thread.java:833)

补充信息

warn: Lagrange.OneBot.Core.Operation.OperationService[0] Unexpected error encountered while handling message. System.Exception: Encode failed at Lagrange.OneBot.Message.Entity.RecordSegment.Build(MessageBuilder builder, SegmentBase segment) at Lagrange.OneBot.Core.Operation.Message.MessageCommon.BuildMessages(MessageBuilder builder, List`1 segments) at Lagrange.OneBot.Core.Operation.Message.SendGroupMessageOperation.HandleOperation(BotContext context, JsonNode payload) at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(MsgRecvEventArgs e)

MrXiaoM commented 6 months ago

看起来应该是 Lagrange 无法编码语音文件。 不清楚为什么语音链接base64后面是四个斜杠,有可能是这里导致 Lagrange 无法正确解析语音文件。 最新版优化了消息中的链接显示,添加了文件类型识别,可尝试使用最新版看看输出的信息如何

onlyzqy commented 6 months ago

使用2d54df9新版,语音输出依旧存在问题 Overflow端日志如下: 2024-03-10 00:01:02 W/Onebot: Request failed: [send_group_msg] app=Lagrange.OneBot v0.0.3, message=, retJson={"status":"failed","retcode":200,"data":null,"echo":107} 2024-03-10 00:01:02 V/Bot.2411510662: Group(937068620) <- [overflow:audio,file=base64:////FcQBPiYAFAIoCjVu8AAQA... (about 63.67 KB)]

网络日志如下: 2024-03-10 00:01:02 D/Onebot: Client received <-- {"status":"failed","retcode":200,"data":null,"echo":107} 2024-03-10 00:01:02 W/Onebot: Request failed: [send_group_msg] app=Lagrange.OneBot v0.0.3, message=, retJson={"status":"failed","retcode":200,"data":null,"echo":107} 2024-03-10 00:01:02 V/Onebot: Stacktrace: cn.evolvefield.onebot.client.util.ActionFailedException: app=Lagrange.OneBot v0.0.3, message=, retJson={"status":"failed","retcode":200,"data":null,"echo":107} at cn.evolvefield.onebot.client.util.ActionSendRequest.send(ActionSendRequest.kt:68) at cn.evolvefield.onebot.client.util.ActionSendRequest$send$1.invokeSuspend(ActionSendRequest.kt) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:33) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46) at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:178) at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:166) at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:397) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:431) at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl$default(CancellableContinuationImpl.kt:420) at kotlinx.coroutines.CancellableContinuationImpl.resumeWith(CancellableContinuationImpl.kt:328) at kotlinx.coroutines.ResumeAwaitOnCompletion.invoke(JobSupport.kt:1413) at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.kt:318) at kotlinx.coroutines.JobSupport.tryFinalizeSimpleState(JobSupport.kt:295) at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:856) at kotlinx.coroutines.JobSupport.makeCompleting$kotlinx_coroutines_core(JobSupport.kt:806) at kotlinx.coroutines.CompletableDeferredImpl.complete(CompletableDeferred.kt:92) at cn.evolvefield.onebot.client.util.ActionSendRequest.onCallback(ActionSendRequest.kt:81) at cn.evolvefield.onebot.client.handler.ActionHandler.onReceiveActionResp(ActionHandler.kt:38) at cn.evolvefield.onebot.client.connection.IAdapter$DefaultImpls.onReceiveMessage(IAdapter.kt:27) at cn.evolvefield.onebot.client.connection.WSClient.onReceiveMessage(WSClient.kt:19) at cn.evolvefield.onebot.client.connection.WSClient.onMessage(WSClient.kt:45) at top.mrxiaom.overflow.internal.deps.websocket.client.WebSocketClient.onWebsocketMessage(WebSocketClient.java:636) at top.mrxiaom.overflow.internal.deps.websocket.drafts.Draft_6455.processFrameText(Draft_6455.java:986) at top.mrxiaom.overflow.internal.deps.websocket.drafts.Draft_6455.processFrame(Draft_6455.java:910) at top.mrxiaom.overflow.internal.deps.websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:402) at top.mrxiaom.overflow.internal.deps.websocket.WebSocketImpl.decode(WebSocketImpl.java:234) at top.mrxiaom.overflow.internal.deps.websocket.client.WebSocketClient.run(WebSocketClient.java:516) at java.base/java.lang.Thread.run(Thread.java:833)

Lagrange端警告日志与之前相同

MrXiaoM commented 6 months ago

待发送的语音是如何生成的,可以发一份样品上来吗

LancherM commented 6 months ago

我遇到了相似的问题,我的语音生成实现是

byte[] bytes = Files.readAllBytes(Paths.get(path));
String base64 = Base64.getEncoder().encodeToString(bytes);
Audio audio = OverflowAPI.get().audioFromFile("base64://"+ base64);
sender.sendMessage(audio);

网络日志

2024-03-19 23:13:52 W/Onebot: Request failed: [send_group_msg] app=Lagrange.OneBot v0.0.3, message=, retJson={"status":"failed","retcode":200,"data":null,"echo":6}
2024-03-19 23:13:52 V/Bot.xxxxxx: Group(xxxxx) <- [overflow:audio,file=base64://UklGRiR3AQBXQVZFZm10IBA... (webp, about 93.79 KB)]

lagrange端日志

warn: Lagrange.OneBot.Core.Operation.OperationService[0]
      Unexpected error encountered while handling message.
      System.NotImplementedException: The method or operation is not implemented.
         at Lagrange.OneBot.Message.Entity.RecordSegment.ConvertFormat(Byte[] audio, Double& audioTime)
         at Lagrange.OneBot.Message.Entity.RecordSegment.Build(MessageBuilder builder, SegmentBase segment)
         at Lagrange.OneBot.Core.Operation.Message.MessageCommon.BuildMessages(MessageBuilder builder, List`1 segments)
         at Lagrange.OneBot.Core.Operation.Message.MessageCommon.ParseChain(OneBotGroupMessage message)
         at Lagrange.OneBot.Core.Operation.Message.SendGroupMessageOperation.HandleOperation(BotContext context, JsonNode payload)
         at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(MsgRecvEventArgs e)
LancherM commented 6 months ago

我遇到了相似的问题,我的语音生成实现是

byte[] bytes = Files.readAllBytes(Paths.get(path));
String base64 = Base64.getEncoder().encodeToString(bytes);
Audio audio = OverflowAPI.get().audioFromFile("base64://"+ base64);
sender.sendMessage(audio);

网络日志

2024-03-19 23:13:52 W/Onebot: Request failed: [send_group_msg] app=Lagrange.OneBot v0.0.3, message=, retJson={"status":"failed","retcode":200,"data":null,"echo":6}
2024-03-19 23:13:52 V/Bot.xxxxxx: Group(xxxxx) <- [overflow:audio,file=base64://UklGRiR3AQBXQVZFZm10IBA... (webp, about 93.79 KB)]

lagrange端日志

warn: Lagrange.OneBot.Core.Operation.OperationService[0]
      Unexpected error encountered while handling message.
      System.NotImplementedException: The method or operation is not implemented.
         at Lagrange.OneBot.Message.Entity.RecordSegment.ConvertFormat(Byte[] audio, Double& audioTime)
         at Lagrange.OneBot.Message.Entity.RecordSegment.Build(MessageBuilder builder, SegmentBase segment)
         at Lagrange.OneBot.Core.Operation.Message.MessageCommon.BuildMessages(MessageBuilder builder, List`1 segments)
         at Lagrange.OneBot.Core.Operation.Message.MessageCommon.ParseChain(OneBotGroupMessage message)
         at Lagrange.OneBot.Core.Operation.Message.SendGroupMessageOperation.HandleOperation(BotContext context, JsonNode payload)
         at Lagrange.OneBot.Core.Operation.OperationService.HandleOperation(MsgRecvEventArgs e)

看起来好像必须是silk格式,换成silk格式就能正常发送了

cdc12345 commented 1 week ago

不知道能不能让Overflow支持转换音频格式(