Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

android - Muting the Google voice recognition beep sound

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...