This is stupid simple but I cannot get it to work.
I want to stop recording before the phone speaks something. No data is being passed.
let words = "Hello world"
let utt = AVSpeechUtterance(string:words)
stopRecordingWithCompletion() {
voice.speak(utt)
}
func stopRecordinWithCompletion(closure: () -> Void) {
recognitionRequest?.endAudio()
recognitionRequest = nil
recognitionTask?.cancel()
recognitionTask = nil
let inputNode = audioEngine.inputNode
let bus = 0
inputNode?.removeTap(onBus: bus)
self.audioEngine.stop()
closure()
}
What am I doing wrong?