diff --git a/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt b/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt index e22334690..423ed7fc6 100644 --- a/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt +++ b/local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt @@ -774,6 +774,9 @@ object AgentService : CoroutineScope { // 通知ChatAPI服务终止当前流式请求 chatApiService.cancelCurrentStream() + //结束等待音 + audioPlayer?.stopAudio() + } catch (e: Exception) { Log.e(TAG, "停止AI流输出异常", e) // 确保状态被重置,即使发生异常 @@ -973,8 +976,6 @@ object AgentService : CoroutineScope { responseBuilder.append(token) if (speakResponse && reply && broadcast && token.isNotEmpty()) { ttsService?.speakStream(token) - // 在开始流式TTS时立即停止气泡音 -// audioPlayer?.stopAudio() } if (reply && token.isNotEmpty()) { // 发送流式回复token @@ -1591,7 +1592,7 @@ object AgentService : CoroutineScope { // 新增:超时相关属性 private var timeoutHandler: Handler? = null private var timeoutRunnable: Runnable? = null - private var timeoutSeconds: Long = 10000L // 默认10秒超时 + private var timeoutSeconds: Long = 30000L // 默认10秒超时 /** * 安全检查 MediaPlayer 是否正在播放 diff --git a/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift b/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift index e7f69f96d..32cbf7d71 100644 --- a/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift +++ b/local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift @@ -486,7 +486,7 @@ audioStream.saveAudioDataTo(data: audioData) if interrupted { sendEvent(name: "response_interrupted", data: ["status": "interrupted"]) } - + audioPlayer?.stopAwaitSound() return interrupted } @@ -1256,7 +1256,6 @@ class ChatApiStreamCallback: StreamCallback { if speakResponse && reply && broadcast{ try agentService.azureTtsHelper?.speakStream(token) // 在开始流式TTS时立即停止气泡音 - // try agentService.audioPlayer?.stopAwaitSound() } if (reply && token != "") { try agentService.sendEvent(name: "assistant_token", data: ["token": token])