AVAudioSession error

Hello
I’m having this error after changing the AVAudioSession Active state.

AVAudioSession.mm:646: -[AVAudioSession setActive:withOptions:error:]: Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.

My initial problem is due to a plugin (SpeechKit) i’m running that to do speech recognition. After i use it for the first time i get the above error and my app will never have sound again. I believe this plugin is changing the audio session state internally and messing it.

Another test i have done that will have the same result is to change the audio session state manually anywhere after the app as started:

    NSError* err;
    AVAudioSession *audioSession = [AVAudioSession sharedInstance];
    [audioSession setActive:YES error:&err];

Is there anyway to restore the audio session once i get this error?

Thank you

I am also Facing the same error.
Have tried with couple of unity versions but have the same output. No audio is played.

I’ve solved this by calling UnitySetAudioSessionActive(1) after the detection is complete.

eg.

- (void)recognizer:(SKRecognizer *)recognizer didFinishWithResults:(SKRecognition *)results
{
    DLog(@"Got results.");
    DLog(@"Session id [%@].", [SpeechKit sessionID]); // for debugging purpose: printing out the speechkit session id
   
    NSString* utteranceResult = [[NSMutableArray arrayWithArray:results.results] componentsJoinedByString:@"#"];
   
    DLog(@"Result is -> %@",utteranceResult);
    UnitySetAudioSessionActive(1);
}