我有一个奇怪的错误,仅在iPad物理设备,iPhone物理设备和所有iPad模拟器上都可以正常工作,但是在iPad物理设备上,我得到了Error Domain = kAFAssistantErrorDomain Code = 1700。这怎么可能发生?
我的SFSpeechRecognizer代码:
func requestTranscribePermissions() {
SFSpeechRecognizer.requestAuthorization { [unowned self] authStatus in
DispatchQueue.main.async {
if authStatus == .authorized {
print("Good to go!")
} else {
print("Transcription permission was declined.")
}
}
}
}
func convertAudioToText() {
if let file = audio {
print(file)
let recognizer = SFSpeechRecognizer(locale: Locale(identifier: "en-US"))
let request = SFSpeechURLRecognitionRequest(url: file)
request.shouldReportPartialResults = false
if (recognizer?.isAvailable)! {
recognizer?.recognitionTask(with: request) { result, error in
guard error == nil else { print("Error: \(error!)"); return }
guard let result = result else { print("No result!"); return }
self.text = result.bestTranscription.formattedString
self.performSegue(withIdentifier: "Convert", sender: nil)
print(result.bestTranscription.formattedString)
}
} else {
print("Device doesn't support speech recognition")
}
} else {
let alert = UIAlertController(title: "There's no audio", message: "No audio recorded", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: NSLocalizedString("OK", comment: "Default action"), style: .default, handler: { _ in
NSLog("The \"OK\" alert occured.")
}))
self.present(alert, animated: true, completion: nil)
}
}
仅在iPad phycal设备上获得:
[[实用程序] + [AFAggregator logDictationFailedWithError:]错误域= kAFAssistantErrorDomain代码= 1700“(空)”错误:错误域= kAFAssistantErrorDomain代码= 1700“(空)”
我在我的应用中存在相同的错误。该错误已修复,将我的iPhone从iOS 13.4.2更新为13.5.1,并将XCode更新为11.5。希望有帮助。