Muting SpeechRecognizer's beep sound

2019-08-10 05:50发布

I'm using SpeechRecognizer API for my app, and everytime it starts, it plays "beep" sound.

I'd like to know how to mute it, So I could implement one of my own.

Thanks.

1条回答
Root(大扎)
2楼-- · 2019-08-10 06:31

If you are using a button to activate and deactivate the recognizer you can mute sound onclick. This doesnt work fantastically if you have it listening constantly, however for button clicks it should be fine :)

private AudioManager manager;
manager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    if (isChecked)
    {
        manager.setStreamMute(AudioManager.STREAM_MUSIC, true);
        speech.startListening(recognizerIntent);

    }
    else
    {
        manager.setStreamMute(AudioManager.STREAM_MUSIC, false);
        speech.stopListening();
        speech.cancel();
    }

Hope this helps (sorry if this is abit of a necrothread)

查看更多
登录 后发表回答