[英]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 存在:
Hey Siri is not enabled on the device.嘿 Siri 未在设备上启用。 Toggle on Settings -> Siri & Search -> Listen for “Hey Siri” (iOS 15)
切换设置 -> Siri 和搜索 -> 聆听“嘿 Siri”(iOS 15)
According to the documentation: for some languages, the recognizer might require an Internet connection根据文档: 对于某些语言,识别器可能需要 Internet 连接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.