Browse Source

Merge branch 'new_dev' of https://github.com/deepcloud2048/deep_voice into new_dev

newdev_shunjiawei
tanlongsheng 10 months ago
parent
commit
73bc497a87
  1. 12
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/AgentService.kt
  2. 9
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

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

@ -528,10 +528,12 @@ object AgentService : CoroutineScope {
try {
delay(idleSeconds * 1000L)
Log.d(TAG, "空闲检测触发自动停止,isActive: $isActive, isRecognitionActive: $isRecognitionActive, isTtsSpeaking: $isTtsSpeaking, isAiStreaming: $isAiStreaming, mode: $mode")
if (isActive && isRecognitionActive && !isTtsSpeaking && !isAiStreaming && mode != "phone_call") {
if (isActive && isRecognitionActive && !isTtsSpeaking && !isAiStreaming) {
Log.d(TAG, "空闲检测触发自动停止,模式: $currentRecognitionMode")
BleService.closeCodec()
stopRecognition()
BleService.closeCodec()
if (mode != "phone_call"){
stopRecognition()
}
sendEvent(
"auto_stop",
mapOf(
@ -541,10 +543,6 @@ object AgentService : CoroutineScope {
)
)
}
if (isActive && isRecognitionActive && !isTtsSpeaking && !isAiStreaming && mode == "phone_call") {
Log.d(TAG, "空闲检测触发自动停止,模式: $currentRecognitionMode")
startRecognition(false, mode)
}
} catch (e: CancellationException) {
// 协程被取消,正常行为
} catch (e: Exception) {

9
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift

@ -409,9 +409,12 @@ class AgentServiceImpl: NSObject {
log: self.logger,
type: .info,
self.currentRecognitionMode)
if self.isRecognizing && !self.isSpeaking && !self.isAiStreaming {
//打电话模式下面 不能关闭识别器
if self.isRecognizing && !self.isSpeaking && !self.isAiStreaming{
BleService.shared.closeCodec()
self.stopRecognition()
if (currentRecognitionMode != "phone_call"){
self.stopRecognition()
}
self.sendEvent(name: "auto_stop", data: [
"reason": "idle_timeout",
"seconds": idleSeconds,
@ -496,7 +499,7 @@ class AgentServiceImpl: NSObject {
sendError("启动语音识别失败", code: "RECOGNITION_START_ERROR")
return false
}
if(useBle){
if(useBle){
isKeepResult = true
}
// 根据模式启动相应的空闲检测(此处 guard isRecognizing,会在 onSessionStarted 中再次启动)

Loading…
Cancel
Save