Reputation: 66
I'm working with the new Apple Speech library and I can't find a command to flip the isFinal bool and end the transcription after a few seconds of silence. Does anyone know how to end the task after a bit of silence?
Here is the code which I receive speech transcription results.
recognitionRequest.shouldReportPartialResults = true
speechRecogTask = speechRecognizer.recognitionTask(with: recognitionRequest, resultHandler: { (result, error) in
var isFinal = false
if result != nil {
self.textField.text = result?.bestTranscription.formattedString
isFinal = (result?.isFinal)!
}
if error != nil || isFinal {
self.audioEngine.stop()
inputNode.removeTap(onBus: 0)
self.speechRecogRequest = nil
self.speechRecogTask = nil
}
})
Any ideas?
Upvotes: 3
Views: 3090
Reputation: 1
if let result = result {
if (isFinal == true) {
self.speechRecogTask?.finish()
}
}
Upvotes: 0