Browse Source

9.1修复唤醒异常问题

weicu
fdp 1 year ago
parent
commit
a0eb6acebe
  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 { if self.isRecognizing && !self.isSpeaking && !self.isAiStreaming {
os_log("空闲检测触发自动停止,模式: %{public}@", log: self.logger, type: .info, self.currentRecognitionMode) os_log("空闲检测触发自动停止,模式: %{public}@", log: self.logger, type: .info, self.currentRecognitionMode)
BleService.shared.closeCodec()
self.stopRecognition() self.stopRecognition()
self.sendEvent(name: "auto_stop", data: [ self.sendEvent(name: "auto_stop", data: [
"reason": "idle_timeout", "reason": "idle_timeout",
@ -471,7 +472,7 @@ class AgentServiceImpl: NSObject {
MusicService.shared.resume() MusicService.shared.resume()
} }
//BleService.shared.closeCodec()
// 重置识别模式 // 重置识别模式
currentRecognitionMode = "normal" 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) completion(false)
return return
} }
print("startAudioRecordAsync\(_isContinuousRecognitionActive)") // print("startAudioRecordAsync\(_isContinuousRecognitionActive)")
// 二次校验:stop 可能已发生,确认仍需启动 // // 二次校验:stop 可能已发生,确认仍需启动
guard self._isContinuousRecognitionActive else { // guard self._isContinuousRecognitionActive else {
os_log("已收到停止请求,取消启动音频录制", log: self.log, type: .info) // os_log("已收到停止请求,取消启动音频录制", log: self.log, type: .info)
completion(false) // completion(false)
return // return
} // }
os_log("开始异步启动音频录制", log: self.log, type: .info) os_log("开始异步启动音频录制", log: self.log, type: .info)
@ -388,7 +388,7 @@ public class AzureAsrHelper: NSObject {
public func startContinuousRecognition( public func startContinuousRecognition(
audioSourceType: AudioSourceType = .microphone, audioSourceType: AudioSourceType = .microphone,
audioDataCallback: SimpleAudioReceiver.AudioDataCallback? = nil audioDataCallback: SimpleAudioReceiver.AudioDataCallback? = nil
) -> Bool { ) -> Bool {
guard speechConfig != nil else { guard speechConfig != nil else {
print("语音服务未初始化") print("语音服务未初始化")
return false return false
@ -420,8 +420,9 @@ public class AzureAsrHelper: NSObject {
} }
print("startContinuousRecognition:\(audioSourceType)") print("startContinuousRecognition:\(audioSourceType)")
// 只有在音频启动成功后才设置状态为 true // 移除这里的状态设置,等音频启动成功后再设置
self._isContinuousRecognitionActive = true // self._isContinuousRecognitionActive = true
// 异步启动音频处理 // 异步启动音频处理
startAudioRecordAsync(audioSourceType: audioSourceType, audioDataCallback: audioDataCallback) { [weak self] (success: Bool) in startAudioRecordAsync(audioSourceType: audioSourceType, audioDataCallback: audioDataCallback) { [weak self] (success: Bool) in
guard let self = self else { return } guard let self = self else { return }
@ -452,7 +453,7 @@ public class AzureAsrHelper: NSObject {
_isContinuousRecognitionActive = false _isContinuousRecognitionActive = false
return false return false
} }
} }

Loading…
Cancel
Save