Mute voice recognition bleep in Bluetooth Earpiece Android

398 Views Asked by At

I'm trying to get continuous voice recognition to work for a custom app on Android, using an ML18 bluetooth headset (by plantronics). I've managed to get rid of the beep produced by my phone by using the answers posted here and managed to route all other media to my bluetooth device using this.

However my bluetooth device is still beeping every time I call SpeechRecognizer.startListening.

Is there something I can do about this, or is this possibly hardwired into the software of the bluetooth device?

If you want to see specific sections of code, let me know. I do not think much of it is relevant however, as the two links above already cover the code that seems most relevant to me. Thanks in advance!

EDIT: So based on the comment below, I've modified my code into the following:

The start listening simply mutes all stream but the alarm stream (undone by unmuting all streams again).

public void startListening() {
    if (canListen) {
        Log.v(TAG, "Starting Listening");
        Intent recognizerIntent = createRecognizerIntent();
        recognizer.cancel();
        recognizer.startListening(recognizerIntent);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            ((AudioManager) getApplicationContext().getSystemService(
                    Context.AUDIO_SERVICE)).setStreamSolo(
                    AudioManager.STREAM_ALARM, true);
        }
    }
}

The Bluetooth receiver does this when the device is connected:

    AudioManager localAudioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
    localAudioManager.setMode(AudioManager.MODE_NORMAL);
    localAudioManager.setBluetoothScoOn(true);
    localAudioManager.startBluetoothSco();

And then in the ACTION_SCO_AUDIO_STATE_UPDATED it sets the mode to AudioManager.MODE_IN_CALL.

Currently the behaviour is as follows: When I first start the app and connect the bluetooth device, as well as trigger the continuous recognition loop, all works as expected. Yet after a first reply has been uttered (using TTS), the beep returns... Again, any help would be appreciated :)

0

There are 0 best solutions below