简体   繁体   English

为什么 SFSpeechRecognizer 在 ipad 中不起作用

[英]Why SFSpeechRecognizer doesn't working in ipad

SFSpeechRecognizer is working well in IOS But it doesn't available in IPAD. SFSpeechRecognizer 在 IOS 中运行良好,但在 IPAD 中不可用。 I don't know how to fix it.我不知道如何修复它。 Please give me a solution.请给我一个解决方案。

func recordAndRecognizeSpeech() {
        
        let node = audioEngine.inputNode
        let recordingFormat = node.outputFormat(forBus: 0)
        node.installTap(onBus: 0, bufferSize: 0, format: recordingFormat) { buffer, _ in
            self.request.append(buffer)
        }
        audioEngine.prepare()
        do {
            try audioEngine.start()
        } catch {
            return print(error)
        }
        guard let myRecognizer = SFSpeechRecognizer() else {
            // A recognizer is not supported for the current locale
            return
        }
        if !myRecognizer.isAvailable {
            print("Speech recognition not available")
            return
        }
        isFinal = false

        recognitionTask = speechRecognizer?.recognitionTask(with: request, resultHandler:  { result, error in
            if let result = result {
                self.recognizedSpeechTextView.text = result.bestTranscription.formattedString
                self.qnaTextField.text = result.bestTranscription.formattedString
                self.textFieldDidChange(self.qnaTextField)

            } else if let error = error {
                print(error)
            }
            
            if !self.isFinal {
                self.startSpeechTimer()
            }
        })
    }

in iPad call function if !myRecognizer.isAvailable { print("Speech recognition not available") return }在 iPad 调用函数中 if !myRecognizer.isAvailable { print("语音识别不可用") return }

At least two possible reasons SFSpeechRecognizer.isAvailable might return false exist:至少有两个可能的原因 SFSpeechRecognizer.isAvailable 可能返回 false 存在:

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

相关问题 SFSpeechRecognizer 在 IOS 13.2 中无法正常工作 - SFSpeechRecognizer isn't working properly in IOS 13.2 Swift SFSpeechRecognizer 不能工作两次 - Swift SFSpeechRecognizer not working twice 为什么我的UIButton不显示在子视图中? iPad应用程式 - Why my UIButton doesn't display in my subview? iPad App 为什么这些约束在iPad 9.7”和12.9”上不能正常工作? - Why aren't these constraints working properly on iPad 9.7“ and 12.9”? 为什么带有MTBBarcodeScanner的iPad上的相机无法正常工作? - Why isn't the camera working on my iPad with MTBBarcodeScanner? SFSpeechRecognizer 在 Ipad 上失败,错误域 = kAFAssistantErrorDomain 代码 = 1700 - SFSpeechRecognizer fails with Error Domain=kAFAssistantErrorDomain Code=1700 on Ipad iPad GCDAsyncSocket无法读取 - iPad GCDAsyncSocket doesn't read 为什么Ipad 3的视口元常量设备宽度返回1536像素而不是768像素? - why doesn't the viewport meta constant device-width return 1536 pixels for the ipad 3 instead of 768 pixels? 为什么#selector不为iPad的键盘快捷方式调用处理程序方法? - Why #selector doesn't call handler method for iPad's keyboard shortcuts? 需要一些帮助,有人知道为什么系统声音在iPad上不起作用而在iPhone上起作用吗? - Need some help, anyone know why system sound isn't working on iPad but is on iPhone?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM