如何忽略SpeechRecognizer的蜂鸣声? [英] How to mute the beep sound for SpeechRecognizer?

查看:739
本文介绍了如何忽略SpeechRecognizer的蜂鸣声?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此之前已经问过,但似乎没有人有一个解决办法:​​静音SpeechRecognizer的蜂鸣声

This has been asked before, but no one seemed to have a solution: Muting SpeechRecognizer's beep sound

尽管如此,我还是想知道是否有人知道如何静音哔声SpeechRecognizer?

Nevertheless, I still would like to know if anyone knows how to mute the beeping sound for SpeechRecognizer?

我创建speechRecognizer对象:私人SpeechRecognizer SR = SpeechRecognizer.createSpeechRecognizer(本);

I create speechRecognizer object: private SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(this);

然后在我的课我实例化speechRecognizer这样

And then in my class I instantiate the speechRecognizer like this

sr.setRecognitionListener(new listener());
Intent i = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
        RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);             
i.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, getApplication()
        .getClass().getName());
i.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, 6);
i.putExtra(RecognizerIntent.EXTRA_PROMPT, "");
i.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_MINIMUM_LENGTH_MILLIS, 7000);
sr.startListening(i);

任何人只要有什么好的建议?我研究,我可以创造AudioManager的对象(的 AudioManager mAudioManager 的),然后使用setStreamSolo(),我可以静音。但我不知道如何实现这一点。我把它添加到我的实例化code为speechRecognizer什么都没有发生。这是不是我应该从我的主类调用?

Anyone with any good ideas? I researched that I could create an object of AudioManager (AudioManager mAudioManager) and then using setStreamSolo(), I could mute the sound. But I am not sure how to implement this. I added it to my instantiation code for speechRecognizer and nothing happened. Is this something I should call from my main class?

mAudioManager.setStreamSolo(AudioManager.STREAM_VOICE_CALL, true);

感谢您提前。

推荐答案

噢我会发表评论,但我没有代表。不过,我想帮助。

Aww I would comment but I don't have the rep. However I would like to help.

你见过这样的:

<一个href=\"http://stackoverflow.com/questions/21701432/continues-speech-recognition-beep-sound-after-google-search-update\">Continues谷歌搜索更新后的语音识别哔声

<一个href=\"http://stackoverflow.com/questions/11699603/is-it-possible-to-turn-off-the-silent-mode-programmatically-in-android\">Is可以在android系统编程关闭静音模式?

静音android系统全球声音

在我看来,该code是不同,这取决于Android版本 - 作为第一个环节表示,谷歌跳槽的嘟嘟媒体流的输出

It seems to me that the code is different depending on the android version - as stated in the first link, Google switched the output of the 'beep' to the media stream.

我猜那些问题之一将有解决方案。如果是的话请发表你做了什么,你说​​很多人似乎有问题。

I am guessing one of those questions will have the solution. If so please post what you have done, as you stated many people seem to be having the problem.

我的猜测是:

//mute audio

AudioManager amanager=(AudioManager)getSystemService(Context.AUDIO_SERVICE);
             amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, true);
             amanager.setStreamMute(AudioManager.STREAM_ALARM, true);
             amanager.setStreamMute(AudioManager.STREAM_MUSIC, true);
             amanager.setStreamMute(AudioManager.STREAM_RING, true);
             amanager.setStreamMute(AudioManager.STREAM_SYSTEM, true);


//unmute audio

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

             amanager.setStreamMute(AudioManager.STREAM_NOTIFICATION, false);
             amanager.setStreamMute(AudioManager.STREAM_ALARM, false);
             amanager.setStreamMute(AudioManager.STREAM_MUSIC, false);
             amanager.setStreamMute(AudioManager.STREAM_RING, false);
             amanager.setStreamMute(AudioManager.STREAM_SYSTEM, false);

我想从证人应用程序的用户将工作这个答案。幸得:@WitnessApplications

I imagine this answer from Witness applications user will work. Credit goes to: @WitnessApplications

另外这个范围会之前,你startListening(I);

这篇关于如何忽略SpeechRecognizer的蜂鸣声?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆