Author Topic: Help with IF statment conditions.  (Read 820 times)

Johndill

  • Newbie
  • *
  • Posts: 3
Help with IF statment conditions.
« on: January 15, 2020, 07:19:56 AM »
Hi, I'm trying out the trial of VA and I'm trying to setup a Star Trek like voice control, for example:

I say "computer", then VA starts listening and it plays sound 1, it waits for another command from the command list to be spoken, but if no command was spoken after 5 seconds it stops listening and plays a rejected sound 2.

However,

If I say "computer", then VA starts listening and it plays sound 1, I say a command I've created in the command list and it activates that command then stops listening and plays a confirming sound 3.

I hope it makes sence, I believe it is possible I'm just not sure how to setup the IF statments for it. Thanks :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: Help with IF statment conditions.
« Reply #1 on: January 15, 2020, 09:13:28 AM »
That could look something like this:
Code: [Select]
Start VoiceAttack listening
Play sound, '{VA_SOUNDS}\sound 1.mp3'
Set date [~timeout] to [~timeout] plus [5] seconds
Set integer [~prevCount] value to the converted value of {CMDCOUNT}
Start Loop While : [~timeout] Is After Current Date/Time
    Begin Text Compare : [{EXP: {CMDCOUNT} > {INT:~prevCount}}] Equals '1'
        Stop VoiceAttack listening
        Play sound, '{VA_SOUNDS}\sound 3.mp3'
    End Condition - Exit when condition met
End Loop
Stop VoiceAttack listening
Play sound, '{VA_SOUNDS}\sound 2.mp3'

Note, however, that there is no native method for getting only the spoken command count, so the confirming sound would also play if you execute a command using other means during those five seconds (E.G. using a keyboard key).

Johndill

  • Newbie
  • *
  • Posts: 3
Re: Help with IF statment conditions.
« Reply #2 on: January 15, 2020, 03:41:08 PM »
Hi, Thank you very much for that, I would never have figured that command out before the trial ends.  :D

It works just how I wanted however there is now another issue, every time I say Computer, after 1 second it always has an unrecognized "who" which prevents me from saying another command in that time, for example I'm using the "calculator" command to test it it out...

As you can see in the attached screenshot, the computer command works, I stay silent for 1 second and it has an unrecognized "who", it times out and stops listening as it should...

The next two is me saying calculator after saying computer, exept it shows as "who calculated" and doesn't work...

The last one, I say computer and wait 1 second, the unrecognized "who" shows up, then I say my command and it works.

What is this unrecognized "who"? I'm not saying anything yet it shows unrecognized "who", it's like it's trying to pickup a continued sentince or something. Thanks :-)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4761
  • RTFM
Re: Help with IF statment conditions.
« Reply #3 on: January 15, 2020, 04:08:36 PM »
I would never have figured that command out before the trial ends.
The trial is not time-limited (it used to be, but that was changed a long while ago).


Have you trained your speech recognition profile? At least three training sessions is recommended (see this post for instructions on how to start the training).

If you still have issues with "who" being recognized after that, you could try adding that to the list of "Recognition Prefix Exclusions" on the "Recognition" tab of the VoiceAttack options window.

The "I'm not saying anything but VoiceAttack keeps hearing things" of this topic may also offer some advice.

Johndill

  • Newbie
  • *
  • Posts: 3
Re: Help with IF statment conditions.
« Reply #4 on: January 15, 2020, 07:36:38 PM »
HAHAHA! Thanks for the helpful links, it helped me figure it out! The beep sound I am using (sound1) is being picked up as "who", here is the link to the sound I'm using if you want to give it a go. :D Thanks again for all your help! :)
https://www.trekcore.com/audio/computer/computerbeep_54.mp3

I changed my start sound to this one and it no longer thinks it's "who" and works.  :)
https://www.trekcore.com/audio/computer/computerbeep_42.mp3
« Last Edit: January 16, 2020, 01:25:48 AM by Johndill »