4

enter image description here

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

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
NAVEEN MISHRA
  • 51
  • 1
  • 3

2 Answers2

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

dzhimc
  • 11
  • 1
0

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.

  • It should be working, because xamarin android use the native code (but on C#). Someone already asked similar question on stack overflow and implement this code on java. – Vincent Elbert Budiman May 18 '18 at 11:55