SpeechRecognizer - time limit

I am using SppechRecognizer for a voice recognition application. His work is wonderful. My requirement: I want to stop listening to the voice after 1 second or 2 seconds. How to achieve this?

+3
source share
1 answer

1 or 2 seconds does not seem to have much time, but if you want to set a time limit, you probably have to insert it. Android has some standard settings for setting the minimum length of voice input and the maximum number after the user stops talking, but none sets the maximum time period for speech input.

It would be best to sink some kind of timer, something like CountDownTimer :

yourSpeechListener.startListening(yourRecognizerIntent); new CountDownTimer(2000, 1000) { public void onTick(long millisUntilFinished) { //do nothing, just let it tick } public void onFinish() { yourSpeechListener.stopListening(); } }.start(); 

I would also advise you to look at the additional features available for RecognizerIntent to find out if something is more suitable for your needs.

+8
source

Source: https://habr.com/ru/post/1247961/


All Articles