Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run SpeechRecognizer during call

Tags:

java

android

Is there a way to run SpeechRecognizer while being in a call? I have done it this way:

  • BroadcastReceiver handles change in phone state (e.g. offhook).
  • the SpeechRecognizer is started in the current (main) thread, as it can only be started in the main thread. The application context is used for the recognizer (the current context, given to the broadcast receiver, can't start be used)

But unfortunately, the person on the other side can't hear me (the speech recognition works fine though). In away, the recognizer has "consumed" my voice and doesn't send it over.

I'm aware that doing things in the main thread during call is dangerous, but is there a way to run the recognizer somehow during call?

Update: I am trying the TelephonyManager listener instead of a BroadcastReceiver, but some internal services blow with NPEs.

like image 579
Bozho Avatar asked Nov 04 '22 18:11

Bozho


1 Answers

AFAIK the voice call is never handled from the Android side. Either Application processor or Communication processor has control over stream at any given time not both. Usually as soon as voice call starts the mic and headset stream control is given to Communication processor. Strangely in your case Application processor is getting control. This looks to be a bug.

The Audio stream is directly processed by the Communication processor (which makes sense since it is waste of processing to do it twice once in application processor and once in communication processor which will eventually handle the call). So i dont think this is possible.

like image 163
nandeesh Avatar answered Nov 12 '22 18:11

nandeesh