Author Topic: Ignoring words in a phrase  (Read 5956 times)

KuruptU4Fun

  • Guest
Ignoring words in a phrase
« on: December 27, 2016, 03:12:17 PM »
I've got a script that ends with a sound clip asking me if I need anything else, to which there are two answers yes or no. Which would prompt either another sound clip to end the conversation (no thanks) or yes to take an alternate path?

How do i go about getting VA to recognize yes or no in a conditional block? How about if it's in the middle of something like "No thank you"?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Ignoring words in a phrase
« Reply #1 on: December 27, 2016, 03:51:06 PM »
If you're trying to do this within the same command, you can do it like this:

Code: [Select]
Start Loop While : [DictationComplete] Equals False
    Start Dictation Mode (Clearing Dictation Buffer)
    Start Loop While : [{DICTATION}] Equals ''
    End Loop
    Stop Dictation Mode
    Begin Text Compare : [{DICTATION}] Contains 'Yes'
        Write '[Purple] Yes' to log
        Set Boolean [DictationComplete] to True
    Else If Text Compare : [{DICTATION}] Contains 'No'
        Write '[Purple] No' to log
        Set Boolean [DictationComplete] to True
    Else
        Say, 'Please say "Yes" or "No"'
    End Condition
End Loop
You can remove the "Else" section and it'll just silently reset the dictation buffer, if you prefer.


Note that with this example, you're counting on the speech engine properly recognizing very short words like "Yes" and "No"(which I've found is true even when using them as command names); You may find it easier to use longer ones like "Affirmative" and "Negative".

KuruptU4Fun

  • Guest
Re: Ignoring words in a phrase
« Reply #2 on: December 27, 2016, 05:09:19 PM »
Thanks Pfiel, I had a quick question and then need some further assistance:

My question is that is my line looks like this:
Start Loop While : [{Dictation}] Equals ['']
While your line looks like this:
Start Loop While : [{DICTATION}] Equals ''
what do I need to change to match yours?

I altered something below you could hopefully help me with as well. I've added responses to that loop:

 Start Loop While : [DictationComplete] Equals False
    Start Dictation Mode (Clearing Dictation Buffer)
    Start Loop While : [{Dictation}] Equals ['']
    End Loop
    Stop Dictation Mode
    Begin Text Compare : [{Dictation}] Contains 'Yes'
        Write '[Purple] Yes' to log
        Set Boolean [DictationComplete] to True
        Play random sound (from directory: {VA_SOUNDS}\MP Ship Full\Chit-Chat\What Can I Do - suppress repeats)
    Else If Text Compare : [{Dictation}] Contains 'No'
        Write '[Purple] No' to log
        Set Boolean [DictationComplete] to True
        Play random sound (from directory: {VA_SOUNDS}\MP Ship Full\Acknowledgements\Welcome - suppress repeats)
    End Condition
End Loop

If by saying "Yes" can I get the sound to respond with the "What can I do" directory
and by saying "No" I get a sound clip of "You're Welcome" like this or does that need to be external from this

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Ignoring words in a phrase
« Reply #3 on: December 27, 2016, 05:29:20 PM »
my line looks like this:
Start Loop While : [{Dictation}] Equals ['']
While your line looks like this:
Start Loop While : [{DICTATION}] Equals ''
what do I need to change to match yours?
You need to use the "Text" textbox(by clicking the radio button next to it) rather than the "Another Variable" textbox, and leave it blank.

If by saying "Yes" can I get the sound to respond with the "What can I do" directory
and by saying "No" I get a sound clip of "You're Welcome" like this or does that need to be external from this
I'm not sure what you're asking. From what I can see you should get a randomly selected response from the directory you've selected. At least once you fix the loop mentioned above, so you get more than a few milliseconds to speak a response ;)

Akoa0013

  • Newbie
  • *
  • Posts: 10
Re: Ignoring words in a phrase
« Reply #4 on: January 05, 2017, 09:47:52 AM »
So I'm pretty sure I've coped the commands well enough. Got it to run once and worked, but then when I ask again it will not run. Almost like it doesn't want to run to loop again or isn't listening for the "yes" or the "no".
Is there any chance you could upload this to see what I did wrong?
« Last Edit: January 05, 2017, 09:58:01 AM by Akoa0013 »

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Ignoring words in a phrase
« Reply #5 on: January 05, 2017, 10:04:10 AM »
So I'm pretty sure I've coped the commands well enough. Got it to run once and worked, but then when I ask again it will not run again.
Is there any chance you could upload this to see what I did wrong?
That's on me. Once you set "DictationComplete" to true, it doesn't get returned to false, so the command won't run properly again.

All you should need to do is add the following line to the top of the action list:
Code: [Select]
Set Boolean [DictationComplete] to False

Alternatively, you can make the variable command-scoped(v1.6.1.4 or later required):
Code: [Select]
Start Loop While : [~DictationComplete] Equals False
    Start Dictation Mode (Clearing Dictation Buffer)
    Start Loop While : [{DICTATION}] Equals ''
    End Loop
    Stop Dictation Mode
    Begin Text Compare : [{DICTATION}] Contains 'Yes'
        Write '[Purple] Yes' to log
        Set Boolean [~DictationComplete] to True
    Else If Text Compare : [{DICTATION}] Contains 'No'
        Write '[Purple] No' to log
        Set Boolean [~DictationComplete] to True
    Else
        Say, 'Please say "Yes" or "No"'
    End Condition
End Loop
The "~" character in front of the variable name means the value of "DictationComplete" will be reset to "Not Set" after the command is stopped.

Akoa0013

  • Newbie
  • *
  • Posts: 10
Re: Ignoring words in a phrase
« Reply #6 on: January 06, 2017, 01:59:33 PM »
Thank you, It's working now. I'll see what fun things I can use for this once I play with it a bit more and understand each line.

One last thing I don't know how to put in is the :
    Else
        Say, 'Please say "Yes" or "No"'
I can put the "Else" but I'm not sure how to put the line below it. Is it a comment or does it show up in the man view for VoiceAttack if it can't recognize Affirmative or Negative?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Ignoring words in a phrase
« Reply #7 on: January 06, 2017, 02:23:11 PM »
If you mean
Code: [Select]
Say, 'Please say "Yes" or "No"'That's a "Say Something with Text-To-Speech" action that simply says that phrase aloud in case the dictation text is something other than "Yes" or "No".