Browse Source

9.1修复唤醒异常问题

newdev_shunjiawei
fdp 1 year ago
parent
commit
14ac0504ee
  1. 3
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift
  2. 23
      local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureAsrHelper.swift

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

@ -354,6 +354,7 @@ class AgentServiceImpl: NSObject {
if self.isRecognizing && !self.isSpeaking && !self.isAiStreaming {
os_log("空闲检测触发自动停止,模式: %{public}@", log: self.logger, type: .info, self.currentRecognitionMode)
BleService.shared.closeCodec()
self.stopRecognition()
self.sendEvent(name: "auto_stop", data: [
"reason": "idle_timeout",
@ -471,7 +472,7 @@ class AgentServiceImpl: NSObject {
MusicService.shared.resume()
}
//BleService.shared.closeCodec()
// 重置识别模式
currentRecognitionMode = "normal"

23
local_plugins/azure_speech/ios/azure_speech/Sources/azure_speech/AzureAsrHelper.swift

@ -264,13 +264,13 @@ public class AzureAsrHelper: NSObject {
completion(false)
return
}
print("startAudioRecordAsync\(_isContinuousRecognitionActive)")
// 二次校验:stop 可能已发生,确认仍需启动
guard self._isContinuousRecognitionActive else {
os_log("已收到停止请求,取消启动音频录制", log: self.log, type: .info)
completion(false)
return
}
// print("startAudioRecordAsync\(_isContinuousRecognitionActive)")
// // 二次校验:stop 可能已发生,确认仍需启动
// guard self._isContinuousRecognitionActive else {
// os_log("已收到停止请求,取消启动音频录制", log: self.log, type: .info)
// completion(false)
// return
// }
os_log("开始异步启动音频录制", log: self.log, type: .info)
@ -388,7 +388,7 @@ public class AzureAsrHelper: NSObject {
public func startContinuousRecognition(
audioSourceType: AudioSourceType = .microphone,
audioDataCallback: SimpleAudioReceiver.AudioDataCallback? = nil
) -> Bool {
) -> Bool {
guard speechConfig != nil else {
print("语音服务未初始化")
return false
@ -420,8 +420,9 @@ public class AzureAsrHelper: NSObject {
}
print("startContinuousRecognition:\(audioSourceType)")
// 只有在音频启动成功后才设置状态为 true
self._isContinuousRecognitionActive = true
// 移除这里的状态设置,等音频启动成功后再设置
// self._isContinuousRecognitionActive = true
// 异步启动音频处理
startAudioRecordAsync(audioSourceType: audioSourceType, audioDataCallback: audioDataCallback) { [weak self] (success: Bool) in
guard let self = self else { return }
@ -452,7 +453,7 @@ public class AzureAsrHelper: NSObject {
_isContinuousRecognitionActive = false
return false
}
}
}

Loading…
Cancel
Save