11

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
  • 2,411
  • 3
  • 22
  • 31
  • Possible duplicate of [How to mute the beep sound for SpeechRecognizer?](http://stackoverflow.com/questions/25538752/how-to-mute-the-beep-sound-for-speechrecognizer) – OneCricketeer Jun 09 '16 at 19:46
  • Hey, i have checked those earlier and as i mentioned in the question that muting the music stream is not a solution for me :/ – con_9 Jun 09 '16 at 20:06
  • Hmm, well, I do remember reading once that muting the voice activation was looked at for legal reasons because that could be an invasion of privacy if a device was always listening without the user's approval or notice. I do see many duplicates on the matter, but if those don't work, then I'm not sure what to tell you. – OneCricketeer Jun 09 '16 at 20:16
  • I do understand the user should privacy part and I am taking care of that thingy – con_9 Jun 09 '16 at 20:20
  • Is your application a System application and/or has root access? – brandall Jun 13 '16 at 10:21

4 Answers4

6

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.

Community
  • 1
  • 1
REG1
  • 486
  • 4
  • 15
  • 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. – con_9 Jun 17 '16 at 19:48
  • 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: http://android.stackexchange.com/questions/128588/how-do-i-disable-the-google-voice-typing-voice-search-ding-sound. – REG1 Jun 17 '16 at 21:38
  • i am fine with rooting. I will have to see that link – con_9 Jun 18 '16 at 05:32
  • 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 ! – con_9 Jun 19 '16 at 19:04
  • @con_9 I included the link per your request. I'm glad it could help you further. – REG1 Jun 19 '16 at 22:16
  • @con_9 Just incase: Here is another thread on the same method that uses root access: http://forum.joaoapps.com/index.php?threads/turn-off-avc-beep-solved.2626/ – REG1 Jun 19 '16 at 22:45
  • i saw that earlier and that appears outdated. i mentioned it in my question :-) – con_9 Jun 20 '16 at 11:50
  • audio focus won't work: https://stackoverflow.com/questions/45380043/stop-speechrecognizer-from-requesting-audio-focus – user25 Jul 28 '17 at 19:04
5

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

  • 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. – con_9 Jun 15 '16 at 05:31
  • @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 – Sergio Antonio Snchez Camarero Jun 15 '16 at 07:02
  • any news about muting only beep sound without muting music stream? – user25 Jul 28 '17 at 19:06
2

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);
NIPHIN
  • 1,043
  • 1
  • 8
  • 16
0

I found another solution witch works fine for me. I set the audio stream of the media player to another stream, so i could mute the music stream. I hope that helps somebody else too.

afd = context.getResources().openRawResourceFd(R.raw.duduuudududu2);

mp.reset();
mp.setAudioStreamType(AudioManager.STREAM_ALARM);
myAudioManager.setStreamVolume(AudioManager.STREAM_MUSIC,0,0);

try 
{
   mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
   mp.prepare();
} 
catch (IOException e) 
{
   e.printStackTrace();
}

mp.start();
Divyang Desai
  • 6,470
  • 11
  • 40
  • 62
jabok r
  • 1
  • 2