speech_recognition
speech_recognition copied to clipboard
Stop listening when voice end
Hi, on Android platform when listening started, user speak some voice and when user stop speaking, application stoped to listen him. On IOS that function dont worked, and application listening all time while user do not clicked on stop button. Is it possible to stop listening user if he finished talking?
I solved that on iOS by using a timer. Every time a new word comes from the speech recognition stream, I call it:
if (forceDetectSpeechDetectionOff) {
_lastWordTimer?.cancel();
_lastWordTimer = Timer(Duration(milliseconds: 1000), () {
recognition.stop();
});
}
@shinayser Hi, i write the same code, works good. Maybe you know how on android set listening only for eng language ? When i start application on phone with rus language, application try to listen rus or eng voice(when i say only one word, in most cases i seen rus text), but when i setup phone on eng language all works fine. This exception of library, in android path.
@antonmolchan @shinayser Guys, sorry for noob question, but how to implement this code?
if (forceDetectSpeechDetectionOff) {
_lastWordTimer?.cancel();
_lastWordTimer = Timer(Duration(milliseconds: 1000), () {
recognition.stop();
});
}
There is no boolean forceDetectSpeechDetectionOff in this package, so as _lastWordTimer definition... Thanks
@tsinis
declare a class Timer variable.. Line: 53
put it on your callback..
Line: 182 to 186
@tsinis declare a class Timer variable.. Line: 53 put it on your callback.. Line: 182 to 186
@monggos Awesome, now I get it, at first I didn’t understand where the Тimer class comes from etc. Now it's works like a charm. Thanks a million!
I am having a problem with IOS, OnRecognitionResultHandler is never called after speaking. As @monggos showed, I did follow the same but not Working Any Suggestions.
@ramsham2411 first, check your callback registration if set correctly.. like this..
Wouldn't it be useful to have an optional timeout to configure (like SpeechTimeout)? It's unexpected that this behavior differs between iOS and Android.