Как спрятать тост: «Ваше аудио будет отправлено в Google для предоставления услуги распознавания речи» в распознаватель речи? - PullRequest
0 голосов
/ 17 мая 2018

enter image description here

Я использую распознаватель речи Google для интеграции голосовых сервисов в Android, но, нажимая на кнопку «Микрофон», появляется это надоедливое тостовое сообщение. Пожалуйста, предложите мне способ скрыть это.

Спасибо

Ответы [ 2 ]

0 голосов
/ 02 июня 2018

Если ваше устройство имеет root-права, вы можете скрыть уведомление, но не можете запретить отправку звука в Google.

Установите Xposed Framework и модуль UnToaster Xposed, затем добавьте: com.google.android.googlequicksearchbox

0 голосов
/ 18 мая 2018

Итак, вы можете настроить свой распознаватель речи, создав его самостоятельно.Я написал этот код на xamarin.android, поэтому он должен быть примерно одинаковым.

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
  }

Мой код - это тип непрерывного распознавания, поэтому я ставлю startover () всякий раз, когда заканчивается речь.Но вы можете настроить это, сделав свой собственный пользовательский интерфейс и т. Д., Просто позвоните startover (); , чтобы начать речь.

...