Version 12.0 beta (12A6159)
iOS14
Simulator
<pre>
if (!self.audioEngine.isRunning) {
self.audioEngine = [[AVAudioEngine alloc] init];
AVAudioInputNode *inputNode = self.audioEngine.inputNode;
AVAudioFormat *nativeAudioFormat = [inputNode inputFormatForBus:0];
_weak typeof(self)weakSelf = self;
[inputNode installTapOnBus:0 bufferSize:1024 format:nativeAudioFormat block:^(AVAudioPCMBuffer * Nonnull buffer, AVAudioTime * _Nonnull when) {
[weakSelf.recognitionRequest appendAudioPCMBuffer:buffer];
}];
[self.audioEngine prepare];
[self.audioEngine startAndReturnError:&error];
if (error) {
[self stop];
[self onError:[NSError errorWithDomain:@"startAudioEngine error" code:0 userInfo:nil]];
}
else {
[self activeStatusChanged:MMSpeechRecognizerActiveStatusStared];
}
}
else {
[self stop];
[NSError errorWithDomain:@"The audio engine is runing" code:0 userInfo:nil];
}
}
</pre>
Crashed at self.audioEngine.inputNode line.
iOS14
Simulator
<pre>
(void)startAudioEngine {
if (!self.audioEngine.isRunning) {
self.audioEngine = [[AVAudioEngine alloc] init];
AVAudioInputNode *inputNode = self.audioEngine.inputNode;
AVAudioFormat *nativeAudioFormat = [inputNode inputFormatForBus:0];
_weak typeof(self)weakSelf = self;
[inputNode installTapOnBus:0 bufferSize:1024 format:nativeAudioFormat block:^(AVAudioPCMBuffer * Nonnull buffer, AVAudioTime * _Nonnull when) {
[weakSelf.recognitionRequest appendAudioPCMBuffer:buffer];
}];
[self.audioEngine prepare];
[self.audioEngine startAndReturnError:&error];
if (error) {
[self stop];
[self onError:[NSError errorWithDomain:@"startAudioEngine error" code:0 userInfo:nil]];
}
else {
[self activeStatusChanged:MMSpeechRecognizerActiveStatusStared];
}
}
else {
[self stop];
[NSError errorWithDomain:@"The audio engine is runing" code:0 userInfo:nil];
}
}
</pre>
Crashed at self.audioEngine.inputNode line.