Muting the Google voice recognition beep sound

12,992

Solution 1

Assuming you don't want to mute all streams because you are interested in playing your own sound, this might be a solution for you: Use the Audio Focus API.

So you would have something like this:

AudioManager am = mContext.getSystemService(Context.AUDIO_SERVICE);
...
// Request audio focus for playback
int result = am.requestAudioFocus(afChangeListener,
                             // Use the music stream.
                             AudioManager.STREAM_MUSIC,
                             // Request permanent focus.
                             AudioManager.AUDIOFOCUS_GAIN);

if (result == AudioManager.AUDIOFOCUS_REQUEST_GRANTED) {
am.registerMediaButtonEventReceiver(RemoteControlReceiver);
// Play your own sound (or play silence)
}
am.abandonAudioFocus(afChangeListener);

I have not tested, whether the Google App (which plays the beep sound) adheres to this request, but generally it should work and its worth giving it a try.

Another option would be to directly mute all sounds coming from the Google App (which includes the Google voice recognition beep sound). The advantage of this method is that there is no interference with any other streaming audio. The following is a link for further detail. Do note, however, that this requires root access: https://android.stackexchange.com/questions/128588/how-do-i-disable-the-google-voice-typing-voice-search-ding-sound.

Solution 2

The only solution I've found to mute beep sound recognition is:

audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audio.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);

Before you should save the volume, for example:

AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
current_volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);

To return to restore the volume level, such as tapeworms:

audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
audio.setStreamVolume(AudioManager.STREAM_MUSIC, audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC),
            AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE);

I hope it helps you on something

Solution 3

You can use audio manager to control the sounds

  AudioManager audioManager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);

before you start recognizing call

 audioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);

and after recognition is complete call

audioManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
Share:
12,992

Related videos on Youtube

con_9
Author by

con_9

Updated on September 22, 2022

Comments

  • con_9
    con_9 over 1 year

    I have a test app that uses Google voice in a continuous manner and it plays the beep sound every time Google recognition service is called. I am trying to get rid of the beep sound. I have read threads of muting the music stream but that would not work for me.

    I am trying to find the beep file location so I could just go and delete it from the system. I followed this thread, but I cannot see the file in 5.0 system file.

  • con_9
    con_9 almost 8 years
    thanks for your reply but I know this solution and i am not looking for this. I do not want to switch to mute and restore the volume level. just beep sound should be removed and all other streams normal volume.
  • Sergio Antonio Snchez Camarero
    Sergio Antonio Snchez Camarero almost 8 years
    @con_9 I know, but the only solution I found was this. This solution is only you mute the volume of music, others are having their level. If you find the solution to mute only the beep of speech recognizer, tell me please
  • con_9
    con_9 almost 8 years
    thank you for your reply. i had read about this api earlier and its a nice thought but "I need to specifically get rid of the beep file!" so that i dont have to deal with these things because even if what are you proposing works, it will interfere with other things like navigation readout while music is playing, what do u say.
  • REG1
    REG1 almost 8 years
    Well, I do not believe it is possible to remove the beep file without the device being rooted. So you'll have to find a way around that. I do not see any way of solving this programmatically. I guess you've seen this thread already: android.stackexchange.com/questions/128588/….
  • con_9
    con_9 almost 8 years
    i am fine with rooting. I will have to see that link
  • con_9
    con_9 almost 8 years
    that link should work i guess, il have to take it from there. il update what i eventually do. Could you please edit your answer and include this link !
  • REG1
    REG1 almost 8 years
    @con_9 I included the link per your request. I'm glad it could help you further.
  • REG1
    REG1 almost 8 years
    @con_9 Just incase: Here is another thread on the same method that uses root access: forum.joaoapps.com/index.php?threads/…
  • con_9
    con_9 almost 8 years
    i saw that earlier and that appears outdated. i mentioned it in my question :-)
  • user25
    user25 over 6 years
  • user25
    user25 over 6 years
    any news about muting only beep sound without muting music stream?