I have an app that keeps on listening to voice and converting it to commands using Google Voice API.
I have been using setStreamMute(AudioManager.STREAM_SYSTEM
The beep sound can be muted by using AudioManager
AudioManager mAudioManager =(AudioManager)getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, true);
To unmute sound
AudioManager mAudioManager =(AudioManager)getSystemService(Context.AUDIO_SERVICE);
mAudioManager.setStreamMute(AudioManager.STREAM_MUSIC, false);
Also add permission to Manifest.xml