Voice Control - finite loop count

Post your questions and help other users.

Moderator: Martin

Post Reply
phenning
Posts: 6
Joined: 18 Dec 2015 04:25

Voice Control - finite loop count

Post by phenning » 07 Jun 2020 09:14

My aim is a better handling of voice control in connection with my SmartHome.

I run Automagic on several Android devices that have the AMAD Flowset to communicate with the SmartHome software FHEM (see http://www.fhem.de).

When I activate the Voice Control in Automagic, I have two different options:

1. Without User Interface -> Then only a beep occurs to signalize to the user that he/she should start to speak. While this is ok, failure to receive such an input results in an audio meesage that the "input could not be detected" (or so, I do not know the English wording of this message). Voice Control therefore stops after the failure to detect audio input. Here, I am searching for two things: a.) setting the timeout for detecting a failure and (more important) b.) suppression of the audio failure message.

2. With User Interface -> The signal to the user is a beep plus a window from com.google.android.googlequicksearchbox showing a microphone. Failure to receive audio input then after timeout results in a modified alert window asking to repeat the audio input. Here then I run into problems. I can easily use the alert window as a trigger, check the window text and, if I wish, click the "Repeat" button with Autonmagic. I can also count the number of repetitions, if also the second, third, ... etc. attempt to detect audio fails. However: Automagic neither allows an infinite number of repetitions, nor does it allow for a controlled exit from this loop.

If I keep the repetitions running indefinitely (without audio input, of course), the Automagic Voice Control action crashes after some 5 repetitions of the sequence "asking for audio input" -> "no audio input" -> "alert window asking for repetition" -> "Automagic pressing the Repeat-button". In the editor, this Action then is kept highlighted, no further audio input may be given. The only way out is to stop Automagic service, and to restart it manually.

Of course it is always (well, at least before the 5th repetition) possible to get out of this loop by providing audio input to the speech recognition engine. But what if nobody is at home?

I'd like to learn about a controlled way to break the Voice Control action without audio input when using the option "With User Interface" - say after a finite number of 3 repetitions. And also I'd like to learn a way to get out of the blocking condition once Voice Control is crashed.

Regards

pah

User avatar
Desmanto
Posts: 2709
Joined: 21 Jul 2017 17:50

Re: Voice Control - finite loop count

Post by Desmanto » 05 Jul 2020 17:23

Without User interface, you can use expression to check if operation == "Cancel", then loop back to input speech. Or you can add execution count to count how many times it fail, before exiting. But you can't set the timeout yet.

With user interface, you can use control UI parallel to the input dialog, to loop sleep and check for the existence of the error.

Code: Select all

existsElementById("com.google.android.googlequicksearchbox:id/intent_api_text");
If this exist, means google faile to catch your voice command, you can then continue to

Code: Select all

clickById("com.google.android.googlequicksearchbox:id/retry_button");
Increment a variable (example retry) by one and count this how many times. After certain times, use back() to exit the voice command.

To catch the crash, add something, example notification on screen to the input dialog, and change the connection to exception. When the error happen, it won't crash the whole flow, it simply continue to the exception branch.
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.

Post Reply