|
|
@ -131,10 +131,17 @@ public class AzureAsrHelper: NSObject { |
|
|
let xunfeiConfigReady = |
|
|
let xunfeiConfigReady = |
|
|
!self.xunfeiAppId.isEmpty && !self.xunfeiAccessKeyId.isEmpty |
|
|
!self.xunfeiAppId.isEmpty && !self.xunfeiAccessKeyId.isEmpty |
|
|
&& !self.xunfeiAccessKeySecret.isEmpty |
|
|
&& !self.xunfeiAccessKeySecret.isEmpty |
|
|
|
|
|
let onlySupportedByXunfei = supportedLanguages.allSatisfy { |
|
|
|
|
|
$0 == "zh-CN" || $0 == "en-US" || $0 == "zh-HK" || $0 == "zh-TW" |
|
|
|
|
|
} |
|
|
|
|
|
let chineseVariants = Set( |
|
|
|
|
|
supportedLanguages |
|
|
|
|
|
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines).lowercased() } |
|
|
|
|
|
.filter { $0 == "zh" || $0.hasPrefix("zh-") } |
|
|
|
|
|
) |
|
|
|
|
|
let hasMultipleChineseVariants = chineseVariants.count >= 2 |
|
|
self.useXunfei = |
|
|
self.useXunfei = |
|
|
supportedLanguages.allSatisfy { |
|
|
onlySupportedByXunfei && xunfeiConfigReady && !hasMultipleChineseVariants |
|
|
$0 == "zh-CN" || $0 == "en-US" || $0 == "zh-HK" || $0 == "zh-TW" |
|
|
|
|
|
} && xunfeiConfigReady |
|
|
|
|
|
|
|
|
|
|
|
os_log( |
|
|
os_log( |
|
|
"ASR helper initialize: supportedLanguages=%{public}@, audioSourceType=%{public}@, xunfeiConfigured=%{public}@, provider=%{public}@", |
|
|
"ASR helper initialize: supportedLanguages=%{public}@, audioSourceType=%{public}@, xunfeiConfigured=%{public}@, provider=%{public}@", |
|
|
@ -1246,4 +1253,3 @@ private class AudioDataCallbackProxy: SimpleAudioReceiver.AudioDataCallback { |
|
|
xunfeiCallback?(data) |
|
|
xunfeiCallback?(data) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|