Browse Source

11

newdev_shunjiawei
fdp 1 year ago
parent
commit
e845d00525
  1. 12
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServiceImpl.swift
  2. 5
      local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServicePlugin.swift

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

@ -75,6 +75,9 @@ class AgentServiceImpl: NSObject {
//是否保留最终结果
private var isKeepResult = true;
// 新增:是否在识别过程中被中断
public var isInterrupt: Bool = true
var currsessionId: String = ""
var language: String = ""
private var serverurl = ""
@ -1664,7 +1667,9 @@ class ChatApiStreamCallback: StreamCallback {
// 停止等待音效
agentService.audioPlayer?.stopAwaitSound()
}
if(agentService.isInterrupt){
BleService.shared.closeCodec()
}
if speakResponse && reply && broadcast && sessionid == agentService.currsessionId{
agentService.azureTtsHelper?.flushStream(sessionid:sessionid)
@ -1829,6 +1834,9 @@ extension AgentServiceImpl: TtsEventListener {
MusicService.shared.reduceVolume()
case .playbackCompleted:
restartIdleCheck()
if(isInterrupt){
BleService.shared.openEncoder()
}
sendEvent(name: "playback_completed", data: ["status": "playback_completed"])
MusicService.shared.restoreVolume()
case .synthesisCanceled:
@ -2132,7 +2140,7 @@ extension AgentServiceImpl: AzureAsrHelper.ContinuousRecognizeCallback {
isStartingRecognition = false
// 使用模式感知的空闲检测启动方法
startIdleCheckForMode(mode: currentRecognitionMode)
if (currentRecognitionMode == "ble_wakeup") {
if (currentRecognitionMode == "ble_wakeup") {
audioPlayer?.playStartSound()
}

5
local_plugins/agent_service/ios/agent_service/Sources/agent_service/AgentServicePlugin.swift

@ -78,7 +78,10 @@ public class AgentServicePlugin: NSObject, FlutterPlugin {
let mode = (call.arguments as? [String: Any])?["mode"] as? String ?? "normal"
impl.startRecognition(mode: mode)
result(true)
case "isInterrupt":
impl.isInterrupt = !impl.isInterrupt
result(impl.isInterrupt)
case "recognizeCallback":
impl.recognizeCallback()
result(true)

Loading…
Cancel
Save