之前有人问过,但似乎没有人有解决方案:
Muting SpeechRecognizer’s beep sound
不过,我仍然想知道是否有人知道如何静音SpeechRecognizer的哔哔声?
我创建了speechRecognizer对象:private SpeechRecognizer sr = SpeechRecognizer.createSpeechRecognizer(this);
然后在我的课堂上我像这样实例化speechRecognizer
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(),我可以静音.但我不确定如何实现这一点.我将它添加到我的speechRecognizer实例化代码中,没有任何反应.这是我应该从我的主课那里打电话的吗?
mAudioManager.setStreamSolo(AudioManager.STREAM_VOICE_CALL,true);
先感谢您.
解决方法
哇我会评论,但我没有代表.不过我想帮忙.
你见过这个吗:
Continues Speech Recognition beep sound after Google Search update
Is it possible to turn off the silent mode programmatically in android?
Mute the global sound in Android
在我看来,代码是不同的取决于Android版本 – 如第一个链接中所述,谷歌将’beep’的输出切换到媒体流.
我猜其中一个问题将有解决方案.如果是这样,请发布您所做的事情,正如您所述,许多人似乎遇到了问题.
我的猜测是:
//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);
我想Witness应用程序用户的答案是可行的.归功于:@WitnessApplications
此范围也可以在startListening(i)之前;