Ionic 5 App crashs on trying to convert speech to text while on call

Hi,
I have a ionic app created where I am using speech to text conversion plugin of cordova. Its working well in android but when trying to use speech recognition feature when on call, the ios application crashes.

Can anyone help me resolve this.
Also want to know how to use exception handling ionic app.

Thanks,
Seema Sharma

Make sure that you are asking permission before initiating speech. please share minimal repo to see

I have already asked for permission.
If used normally, that is if the user is not on call and tries to use that functionality it works well.
Only on call it fails by crashing the app.
Here is my code
initSpeech() {

this.speechRecognition.hasPermission()

  .then((hasPermission: boolean) => {

    console.log(hasPermission)

    if (!hasPermission) {

      this.speechRecognition.requestPermission()

        .then(

          () => console.log('granted'),

          () => console.log('Denied')

        )

    }

  })

}

start() {

this.startrecording = true;

this.startTimer();

// Start the recognition process

this.speechRecognition.startListening()

  .subscribe(

    (matches: Array<string>) => {

      this.voicetext = matches[0];

      if (this.mainForm.controls['comments'].value === '') {

        //  let tempvoice = this.getDate(new Date().toISOString()) + ':  ' + matches[0];

        let tempvoice = matches[0];

        this.mainForm.controls['comments'].setValue(tempvoice);

      }

      else {

        this.tempcomment = this.mainForm.controls['comments'].value + ' ' + this.voicetext;

        this.mainForm.controls['comments'].setValue(this.tempcomment);

      }

      if(this.voicetext.trim()!=''&& !this.isIos())

      {

        this.stop();

      }

    },

    (onerror) => console.log('error:', onerror)

  )

}