Browse Source

fix(agent_service): 修复空闲检测中模式判断和事件发送逻辑

将模式判断变量从`mode`改为`currentRecognitionMode`以保持一致性
移除`auto_stop`事件发送,改为发送`recognition_result`事件
weicu
liwei1dao 9 months ago
parent
commit
80b2ce32f6
  1. 19
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt

19
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt

@ -570,17 +570,24 @@ object AgentService : CoroutineScope {
if (isActive && isRecognitionActive && !isTtsSpeaking && !isAiStreaming) {
Log.d(TAG, "空闲检测触发自动停止,模式: $currentRecognitionMode")
BleService.closeCodec()
if (mode != "phone_call"){
if (currentRecognitionMode != "phone_call"){
stopRecognition()
}
sendEvent(
"auto_stop",
mapOf(
"reason" to "idle_timeout",
"seconds" to idleSeconds,
"mode" to currentRecognitionMode
"recognition_result", mapOf(
"sessionid" to currsessionAsrId,
"text" to recognitionResult,
// "language" to detectedLanguage
)
)
// sendEvent(
// "auto_stop",
// mapOf(
// "reason" to "idle_timeout",
// "seconds" to idleSeconds,
// "mode" to currentRecognitionMode
// )
// )
}
} catch (e: CancellationException) {
// 协程被取消,正常行为

Loading…
Cancel
Save