Author Topic: Yes or No timed response  (Read 4726 times)

mikelimtw

  • Jr. Member
  • **
  • Posts: 51
Yes or No timed response
« on: March 13, 2017, 05:29:58 AM »
I'm trying to get a timed 'Yes' or 'No' response after a voice prompt, but it's not working as expected. Code follows:

Say, 'Would you like a system report'  (and wait until it completes)
Set small int (condition)
  • value to 5

Start Dictation Mode (Clearing Dictation Buffer)
Start Loop While : [{EXP:'{DICTATION:SPACE0}'<>'yes' OR '{DICTATION:SPACE0}'<>'no' OR {SMALL:x} <> 0}] Equals '1'
    Clear Dictation Buffer
    Set small int (condition)
  • value as decremented by 1

    Pause 1 second
End Loop
Stop Dictation Mode
Begin Small Integer Compare :
  • Does Not Equal 0

    Begin Text Compare : [{DICTATION:SPACE0}] Equals 'yes'
        Execute command, 'understood' (and wait until it completes)
        Execute command, 'System report' (and wait until it completes)
    Else If Text Compare : [{DICTATION:SPACE0}] Equals 'no'
        Execute command, 'understood' (and wait until it completes)
        Say, 'Report cancelled.'  (and wait until it completes)
    Else
        Say, 'Invalid command. You may request a system report later if needed.'  (and wait until it completes)
    End Condition
Else
    Say, 'Report cancelled.'  (and wait until it completes)
End Condition

Rhaedas

  • Jr. Member
  • **
  • Posts: 72
Re: Yes or No timed response
« Reply #1 on: March 13, 2017, 08:44:20 AM »
I can't go into coding specifics, but what I did for something like this was make the dictation or command to get the input a separate one from the timer. If it picked up a yes or no or whatever, it would flag a confirmation variable and end. The timer command then would initialize that flag first, start the dictation command, and count down. As it counts down it checks to see if the flag is thrown, and if so, it then kills the dictation command and goes on. If the timer runs out, it also kills the command (to clean up) and then goes the appropriate direction.

Hope that's clear enough.

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 2831
Re: Yes or No timed response
« Reply #2 on: March 13, 2017, 10:25:23 AM »
You might want to look at this thread from the old groups:
https://groups.google.com/forum/#!topic/voiceattack/rWyhE7Qyjco

Using dictation for that kind of thing seems a little dicey.

mikelimtw

  • Jr. Member
  • **
  • Posts: 51
Re: Yes or No timed response
« Reply #3 on: March 15, 2017, 12:09:09 AM »
Thanks Gary, I will check it out. But just out of curiosity, why is using dictation dicey? Yes or No are easy words to distinguish; and with the way my routine is written it will timeout in 5 seconds if it doesn't receive an appropriate answer.

Exergist

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 405
  • Ride the lightning
Re: Yes or No timed response
« Reply #4 on: March 21, 2017, 12:14:19 PM »
Summary - Try out the attached profile and use the "Assign Shepard Class" command. If you like what you see then read on and dig into the code. I'd be happy to explain further.



I've been working on a Mass Effect 3 profile that utilizes multiple queries to get information from the player in order to "teach" VoiceAttack the current state of the game. For example, auto-mapping Shepard's powers requires VoiceAttack to know what powers are available to Shepard. And VoiceAttack needs to know Shepard's class in order to do this.

I've created commands that store the primary information regarding a query as well as the processing of the answer, a query command that actually does the questioning, and response commands that are there to just be placeholders to make VoiceAttack "listen" for the appropriate responses.

The attached profile shows an example of all these components for teaching VoiceAttack Shepard's class.

The command "Assign Shepard Class" sets up prompts (text and spoken) that will be sent to the actual query command. The "User Query" command receives and displays/speaks the prompts, runs a timer that counts down from 5 to 0 in 1 second intervals, activates/deactivates VoiceAttack listening where appropriate, and "activates" a variable that allows for responses to actually do something. The Query and Assign Shepard Class have loops that allow the user multiple attempts to provide valid responses. Then there are responses that can only do something if a specific variable (again defined by the Query command) is set to 1. If a response is recognized (i.e., the user speaks a hard-coded appropriate response) then the query command kicks back to the root "Assign Shepard Class" command and performs processing. 

I'm no professional programmer and I'll bet that veteran VoiceAttack users might have suggestions for how I could improve my methodology and trim any fat, but it works pretty well for me. Yes you have to hard-code the responses as well as the processing that results from each response, but I'm aiming for easy of use. I think it is easier to teach a new user the "rules" for the commands (again through the text/spoken prompts) than to try to anticipate and manage the wide array of responses that could result from dictation-based coding.