I am playing with iOS's speech recognition and added microphone usage request in my Info.plist
. On recording, the app displays a pop up for requesting access as expected
MyApp would like to access the microphone
However, if I wait more than a few seconds to respond, the app crashes with the error message: RPCTimeout.mm:55:_ReportRPCTimeout: Initialize: Mach message timeout. Apparently deadlocked. Aborting now.
The code that caused the crash is the line let node = audioEngine.inputNode
let node = audioEngine.inputNode
let recordingFormat = node.outputFormat(forBus: 0)
node.installTap(onBus: 0, bufferSize: 1024, format: recordingFormat) { buffer, _ in
self.request.append(buffer)
}
I did some research and the common solution to this error is making sure audio setting on the Mac is set to use Internal Speakers for input and output, which I already have.
If I set a guard on the node like below then XCode throws the error: Value of type 'AVAudioInputNode' has no member 'inputNode'
guard let node = audioEngine.inputNode.inputNode else {
return
}