问题描述
SFSpeechRecognizer在IOS中运行良好 但是它在IPAD中不可用。 我不知道该如何解决。 请给我一个解决方案。
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()
}
})
}
在iPad通话中如果!myRecognizer.isAvailable { 打印(“语音识别不可用”) 返回 }
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)