简体   繁体   English

SFSpeechRecognizer 在 Ipad 上失败,错误域 = kAFAssistantErrorDomain 代码 = 1700

[英]SFSpeechRecognizer fails with Error Domain=kAFAssistantErrorDomain Code=1700 on Ipad

I've a strange bug which occur only on iPad physical device, on iPhone physical device and all iPad simulators all works great, but on iPad physical device I get Error Domain=kAFAssistantErrorDomain Code=1700.我有一个奇怪的错误,它只发生在 iPad 物理设备、iPhone 物理设备和所有 iPad 模拟器上都很好用,但是在 iPadError 物理设备上得到错误代码域=124867CZTError 设备。 How this can happen?这怎么可能发生?

My code for SFSpeechRecognizer:我的 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)

        }

} }

Only on iPad phycal device I get:仅在 iPad 物理设备上我得到:

[Utility] +[AFAggregator logDictationFailedWithError:] Error Domain=kAFAssistantErrorDomain Code=1700 "(null)" Error: Error Domain=kAFAssistantErrorDomain Code=1700 "(null)" [实用程序] +[AFAggregator logDictationFailedWithError:] 错误域=kAFAssistantErrorDomain 代码=1700“(空)”错误:错误域=kAFAssistantErrorDomain 代码=1700“(空)”

I had the same error in my app.我的应用程序中出现了同样的错误。 The error was fixed updating my iphone from iOS 13.4.2 to 13.5.1 and XCode to 11.5.该错误已修复,将我的 iphone 从 iOS 13.4.2 更新到 13.5.1 和 XCode 更新到 11.5。 Hope this help.希望这有帮助。

I had this problem on macOS and it was simply due to not requesting authorisation first.我在 macOS 上遇到了这个问题,这仅仅是因为没有先请求授权。

[SFSpeechRecognizer requestAuthorization: ...]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM