|
|
@ -27,6 +27,7 @@ class AgentServiceImpl: NSObject { |
|
|
|
|
|
|
|
|
private var azureSpeechKey: String = "" |
|
|
private var azureSpeechKey: String = "" |
|
|
private var azureSpeechRegion: String = "" |
|
|
private var azureSpeechRegion: String = "" |
|
|
|
|
|
private var config: [String: Any] = [:] |
|
|
|
|
|
|
|
|
private var isSpeaking: Bool = false |
|
|
private var isSpeaking: Bool = false |
|
|
|
|
|
|
|
|
@ -136,6 +137,8 @@ class AgentServiceImpl: NSObject { |
|
|
if isInitialized { return true } |
|
|
if isInitialized { return true } |
|
|
// os_log("initialize: config=%{public}@", log: logger, type: .info, config) |
|
|
// os_log("initialize: config=%{public}@", log: logger, type: .info, config) |
|
|
|
|
|
|
|
|
|
|
|
self.config = config |
|
|
|
|
|
|
|
|
if let openaiApiKey = config["openaiApiKey"] as? String { |
|
|
if let openaiApiKey = config["openaiApiKey"] as? String { |
|
|
self.apiKey = openaiApiKey |
|
|
self.apiKey = openaiApiKey |
|
|
} else { |
|
|
} else { |
|
|
@ -206,7 +209,7 @@ class AgentServiceImpl: NSObject { |
|
|
guard let asrSuccess = azureAsrHelper?.initialize( |
|
|
guard let asrSuccess = azureAsrHelper?.initialize( |
|
|
subscriptionKey: azureSpeechKey, |
|
|
subscriptionKey: azureSpeechKey, |
|
|
region: azureSpeechRegion, |
|
|
region: azureSpeechRegion, |
|
|
supportedLanguages: ["zh-CN"], |
|
|
supportedLanguages: supportedLanguages, |
|
|
audioSourceType: .microphone |
|
|
audioSourceType: .microphone |
|
|
), asrSuccess else { |
|
|
), asrSuccess else { |
|
|
sendError("初始化语音识别服务失败", code: "ASR_INIT_ERROR") |
|
|
sendError("初始化语音识别服务失败", code: "ASR_INIT_ERROR") |
|
|
@ -863,7 +866,7 @@ private func processNavigationCard(_ cardNavigation: [String: Any]) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if languages.isEmpty { |
|
|
if languages.isEmpty { |
|
|
os_log("语言列表为空,使用默认语言", log: logger, type: .warning) |
|
|
os_log("语言列表为空,使用默认语言", log: logger, type: .info) |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|