|
|
|
@ -182,6 +182,14 @@ class AgentServiceImpl: NSObject { |
|
|
|
self.callingTool = callingTool |
|
|
|
} |
|
|
|
|
|
|
|
//加载 isInterrupt 状态 |
|
|
|
loadIsInterruptFromCache() |
|
|
|
if let isttsinterrupt = config["isttsinterrupt"] as? String { |
|
|
|
if (isttsinterrupt == "true"){ |
|
|
|
self.isInterrupt = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if let serverurl = config["serverurl"] as? String { |
|
|
|
self.serverurl = serverurl |
|
|
|
} |
|
|
|
@ -256,8 +264,7 @@ class AgentServiceImpl: NSObject { |
|
|
|
|
|
|
|
if isInitialized { |
|
|
|
loadChatHistory() |
|
|
|
// 从 UserDefaults 加载 isInterrupt 状态 |
|
|
|
loadIsInterruptFromCache() |
|
|
|
|
|
|
|
} |
|
|
|
LocationService.shared.getCurrentLocation() { location in |
|
|
|
// self.locationInfo = location |
|
|
|
@ -552,7 +559,7 @@ class AgentServiceImpl: NSObject { |
|
|
|
return false |
|
|
|
} |
|
|
|
guard let audioStream = azureAsrHelper?.audioStream else { |
|
|
|
os_log("AI音频流未初始化", log: logger,type: .error) |
|
|
|
// os_log("AI音频流未初始化", log: logger,type: .error) |
|
|
|
return false |
|
|
|
} |
|
|
|
audioStream.saveAudioDataTo(data: audioData) |
|
|
|
@ -1787,10 +1794,10 @@ class ChatApiStreamCallback: StreamCallback { |
|
|
|
print("onFunctionCall=functionCall\(functionCall)") |
|
|
|
|
|
|
|
if (name == "exit_interaction") { |
|
|
|
// 关闭编码器 (设备侧) |
|
|
|
BleService.shared.closeCodec() |
|
|
|
agentService.stopRecognition() |
|
|
|
} |
|
|
|
// 关闭编码器 (设备侧) |
|
|
|
BleService.shared.closeCodec() |
|
|
|
agentService.stopRecognition() |
|
|
|
} |
|
|
|
|
|
|
|
try agentService.sendEvent(name: "function_call", data: [ |
|
|
|
"sessionid":sessionid, |
|
|
|
@ -1870,7 +1877,7 @@ extension AgentServiceImpl: TtsEventListener { |
|
|
|
restartIdleCheck() |
|
|
|
sendEvent(name: "tts_started", data: ["status": "started"]) |
|
|
|
audioPlayer?.stopAwaitSound() |
|
|
|
|
|
|
|
|
|
|
|
case .synthesisCompleted: |
|
|
|
isSpeaking = false |
|
|
|
restartIdleCheck() |
|
|
|
@ -1880,10 +1887,13 @@ extension AgentServiceImpl: TtsEventListener { |
|
|
|
restartIdleCheck() |
|
|
|
sendEvent(name: "playback_started", data: ["status": "playback_started"]) |
|
|
|
MusicService.shared.reduceVolume() |
|
|
|
if(isInterrupt){ //播报开始。打断唤醒输入 |
|
|
|
BleService.shared.closeCodec() |
|
|
|
} |
|
|
|
case .playbackCompleted: |
|
|
|
restartIdleCheck() |
|
|
|
if(isInterrupt){ |
|
|
|
BleService.shared.openB1Encoder() |
|
|
|
if(isInterrupt){//播报结束。打开解码器 |
|
|
|
BleService.shared.openB1Encoder() |
|
|
|
} |
|
|
|
sendEvent(name: "playback_completed", data: ["status": "playback_completed"]) |
|
|
|
MusicService.shared.restoreVolume() |
|
|
|
|