|
|
|
@ -509,6 +509,10 @@ class AgentServiceImpl: NSObject { |
|
|
|
} |
|
|
|
} |
|
|
|
stopRecognition() |
|
|
|
if isAiStreaming { |
|
|
|
isAiStreaming = false |
|
|
|
_ = chatApiService?.cancelCurrentStream() |
|
|
|
} |
|
|
|
stopTts() |
|
|
|
|
|
|
|
|
|
|
|
@ -537,7 +541,7 @@ class AgentServiceImpl: NSObject { |
|
|
|
|
|
|
|
print("ai启动语音=\(audioSourceType)=\(useBle)") |
|
|
|
guard let success = azureAsrHelper?.startContinuousRecognition( |
|
|
|
// callback: self, |
|
|
|
mod:self.currentRecognitionMode, |
|
|
|
audioSourceType: audioSourceType, |
|
|
|
isRemoveFirstPunctuation: false |
|
|
|
), success else { |
|
|
|
@ -642,9 +646,6 @@ class AgentServiceImpl: NSObject { |
|
|
|
if text.isEmpty { |
|
|
|
return false |
|
|
|
} |
|
|
|
|
|
|
|
_ = azureTtsHelper?.setSpeechParams(rate: ttsRatePercent, pitch: 0, volume: 100) |
|
|
|
_ = azureTtsHelper?.setPhoneCallMode(mod: currentRecognitionMode) |
|
|
|
return azureTtsHelper?.speakOnce(sessionid:sessionid,text) ?? false |
|
|
|
} |
|
|
|
|
|
|
|
@ -706,8 +707,16 @@ class AgentServiceImpl: NSObject { |
|
|
|
sendError("文本输入不能为空", code: "EMPTY_TEXT") |
|
|
|
return false |
|
|
|
} |
|
|
|
stopIdleCheck() |
|
|
|
if isAiStreaming { |
|
|
|
isAiStreaming = false |
|
|
|
_ = chatApiService?.cancelCurrentStream() |
|
|
|
} |
|
|
|
stopTts() |
|
|
|
currentRecognitionMode = "normal" |
|
|
|
|
|
|
|
os_log("开始处理文本输入", log: logger, type: .info) |
|
|
|
|
|
|
|
processWithChatApiService(sessionid: sessionid, text: text, speakResponse: speakResponse) |
|
|
|
return true |
|
|
|
} |
|
|
|
@ -717,7 +726,8 @@ class AgentServiceImpl: NSObject { |
|
|
|
sendError("ChatAPI服务未初始化", code: "CHATAPI_NOT_INITIALIZED") |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
_ = azureTtsHelper?.setSpeechParams(rate: ttsRatePercent, pitch: 0, volume: 100) |
|
|
|
_ = azureTtsHelper?.setPhoneCallMode(mod: currentRecognitionMode) |
|
|
|
let userMessage = chatApiService.createUserMessage(content: text) |
|
|
|
processWithChatApiServiceInternal(sessionid: sessionid,userMessage: userMessage, displayText: text, speakResponse: speakResponse) |
|
|
|
} |
|
|
|
|