私は続きを実行しようとしています。AVCapture
iOS 10 ベータ版を使用した音声認識。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 == kCMMediaType_Audio) {
// process audio here
m_recognRequest?.appendAudioSampleBuffer(sampleBuffer)
}
return
}
全体が数秒間機能します。その後、captureOutput はもう呼び出されません。appendAudioSampleBuffer(sampleBuffer) という行をコメントアウトすると、アプリが実行されている限り (予想どおり)、captureOutput が呼び出されます。明らかに、サンプル バッファーを音声認識エンジンに入れると、それ以上の実行が何らかの形でブロックされます。しばらくすると、利用可能なバッファが消費され、バッファを取得できないため、プロセスが何らかの形で停止すると思います???
最初の 2 秒間に記録されるすべての情報が正しい認識につながることを言及しておく必要があります。Apple はベータ版のドキュメントにテキストを入れていないので、SFSpeech API が正確にどのように機能しているかはわかりません。ところで: SFSpeechAudioBufferRecognitionRequest.endAudio() の使用方法
ここで何か知っている人はいますか?
ありがとうクリス