我正在努力执行续.AVCapture在iOS 10 beta上使用语音识别.我已经设置captureOutput(...)了不断获得CMSampleBuffers.我将这些缓冲区直接放入SFSpeechAudioBufferRecognitionRequest我之前设置的中,如下所示:
... do some setup
SFSpeechRecognizer.requestAuthorization { authStatus in
if authStatus == SFSpeechRecognizerAuthorizationStatus.authorized {
self.m_recognizer = SFSpeechRecognizer()
self.m_recognRequest = SFSpeechAudioBufferRecognitionRequest()
self.m_recognRequest?.shouldReportPartialResults = false
self.m_isRecording = true
} else {
print("not authorized")
}
}
.... do further setup
func captureOutput(_ captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, from connection: AVCaptureConnection!) {
if(!m_AV_initialized) {
print("captureOutput(...): not initialized !")
return
}
if(!m_isRecording) {
return
}
let formatDesc = CMSampleBufferGetFormatDescription(sampleBuffer)
let mediaType = CMFormatDescriptionGetMediaType(formatDesc!)
if (mediaType …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个应用程序,当用户不知道时,它会显示一个会更改每个级别的文本。目标是说出一个显示的句子(是的,它是为孩子们设计的):
\n\n@IBAction func dontknow(_ sender: Any) {\n let utterance = AVSpeechUtterance(string: textLabel.text)\n utterance.voice = AVSpeechSynthesisVoice(language: "fr-FR")\n utterance.rate = 0.4\n\n let synthesizer = AVSpeechSynthesizer()\n synthesizer.speak(utterance)\n\n}\nRun Code Online (Sandbox Code Playgroud)\n\n该应用程序的构造如下:\n如果用户不知道 -> 他可以单击按钮说出文本\n如果他是对的 -> 他进入下一个级别。
\n\n当他第一次输入要说的按钮时,应用程序会说一些话,但是当用户尝试说出文本并且在下一个级别时,他单击要说的按钮,则什么也没有发生。它只是抛出这个错误:Failure starting audio queue \xe2\x89\xa5\xcb\x9a\xcb\x9b\xcb\x87
完整代码:
\n\nimport UIKit\nimport AVFoundation\nimport Speech\n\nclass ReadViewController: UIViewController, SFSpeechRecognizerDelegate {\n var texts = ["Je mange des p\xc3\xa2tes", "Bonjour Jean comment vas-tu", "Qui est-ce", "J\'en ai marre", "Je ne te trouve pas gentil", "Pourquoi tu ne veux pas","Tu es si gentil", "Tu …Run Code Online (Sandbox Code Playgroud) speech-recognition avfoundation ios swift sfspeechrecognizer