You need to use an input audio stream which has the AcousticEchoCanceler
effect applied.
The SpeechRecognizer
API doesn't have a way to simply turn that on. You need to capture input audio yourself, then pass that into the SpeechRecognizer
through EXTRA_AUDIO_SOURCE
.
The input audio stream needs to be configured in a way that supports the AcousticEchoCanceler
effect. https://stackoverflow.com/a/38021196 has more details on that.
Since you asked about Google Assistant: apps like that probably don't use the SpeechRecognizer
API since they're trying to detect a specific phrase (a more specialized model would be more effective).