How to hide toast“ Your audio will be sent to google to provide speech recognition service.” in Speech Recognizer?

匿名 (未验证) 提交于 2019-12-03 01:18:02

问题:

I am using google speech recognizer for integrating voice services in Android but while pressing on mic buttong this annoying toast message is showing.please suggest me a way to hide this.

Thanks

回答1:

If your device is rooted you can hide the notification, but not prevent the audio from being sent to Google.

Install Xposed framework and module UnToaster Xposed, then add: com.google.android.googlequicksearchbox



回答2:

So what you can do is to customize your speech recognizer by building it by your own. I wrote this code on xamarin.android so it should be pretty similar.

Public class CustomRecognizer : Java.Lang.Object, IRecognitionListener,   TextToSpeech.IOnInitListener { private SpeechRecognizer _speech; private Intent _speechIntent;   public string Words;   public CustomRecognizer(Context _context) {     this._context = _context;     Words = "";     _speech = SpeechRecognizer.CreateSpeechRecognizer(this._context);     _speech.SetRecognitionListener(this);     _speechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);     _speechIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);     _speechIntent.PutExtra(RecognizerIntent.ActionRecognizeSpeech, RecognizerIntent.ExtraPreferOffline);     _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1000);      _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1000);     _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500); }  void startover() {     _speech.Destroy();     _speech = SpeechRecognizer.CreateSpeechRecognizer(this._context);     _speech.SetRecognitionListener(this);     _speechIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);     _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1000);     _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1000);     _speechIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 1500); StartListening(); } public void StartListening() {     _speech.StartListening(_speechIntent); }  public void StopListening() {     _speech.StopListening(); }  public void OnBeginningOfSpeech() {  }  public void OnBufferReceived(byte[] buffer) { }  public void OnEndOfSpeech() {   startover(); }  public void OnError([GeneratedEnum] SpeechRecognizerError error) {     Words = error.ToString();     startover(); }    public void OnResults(Bundle results)   {     var matches = results.GetStringArrayList(SpeechRecognizer.ResultsRecognition);     //do whatever you want for the result   } 

My code is a continuous recognition type,that's why I put startover() whenever the speech end. But you can customize this by making your own UI etc, just call startover(); to begin the speech.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!