Author Topic: How does "Contains" actually work?  (Read 1572 times)

tgsnet

  • Newbie
  • *
  • Posts: 8
How does "Contains" actually work?
« on: May 29, 2021, 10:10:14 AM »
How I imagine "Contains" working is that I can say any word that I assign in the Text input field and this would be stored in the Variable if it is recognized in a phrase that I say.

However when I do that it does not work and VA has been detecting my phrases with the word recognized in the phrase that I am attempting to have recognized.

I've also tried wrapping the word in *'s like: *word* but im not even sure if that is acceptable syntax in that input field.


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4757
  • RTFM
Re: How does "Contains" actually work?
« Reply #1 on: May 29, 2021, 02:53:42 PM »
Have you read the documentation on conditions?

These topics may also be of use in addition to the official documentation:
Control flow (If, Else, ElseIf, Loop, Jump) basics
Variables and tokens summed up


Conditions don't set variables, nor do they influence how a command is recognized.

tgsnet

  • Newbie
  • *
  • Posts: 8
Re: How does "Contains" actually work?
« Reply #2 on: May 29, 2021, 04:19:29 PM »
Have you read the documentation on conditions?

These topics may also be of use in addition to the official documentation:
Control flow (If, Else, ElseIf, Loop, Jump) basics
Variables and tokens summed up


Conditions don't set variables, nor do they influence how a command is recognized.

I'm using "Wait for Spoken response" to set the variable which has four acceptable words "yes;no;parking" because I would like to speak in dynamic responses.

From your link this sentence "In VoiceAttack, when a statement is "True", any action between the "Begin" and "End Condition" actions is executed in a normal "If statement", so in this case the word "Action" will be written to the log in a blue color."

So out of the four spoken words I have set "Contains" does not work how im thinking it will.

For example if I say the one word response "yes" (using a Contains) then it will trigger the next commands that are true within the condition builder.
BUT if i try to say "they are just parking" then it does not trigger "parking" which is contained in that phrase - and it shows up as a unrecognized command.

so how does 'Contains' work? Because it doesnt work for checking to see if a word is contained in a phrase which is what I thoguht it would do.



Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4757
  • RTFM
Re: How does "Contains" actually work?
« Reply #3 on: May 29, 2021, 04:34:17 PM »
Again, conditions don't affect how things are recognized. You pass in a statement, it checks whether that statement evaluates to true or false, and executes a branch accordingly.

The "Contains" operator merely specifies that the condition should check the entire input string for an occurrence of the set of characters entered into the "Text" field, rather than checking whether the entire input string is identical to the set of characters specified in the "Text" field as it would when the "Equals" operator is used.

The "Begin a Conditional (If Statement) Block" action is completely independent of the "Wait For Spoken Response" action. The latter sets a value, the former retrieves that value, they do not interact directly.

The "Wait For Spoken Response" action takes full, predefined phrases. If you specify "parking", you need to speak "parking", nothing more, nothing less. You cannot use wildcards with the "Wait For Spoken Response" action.

As mentioned in the documentation, if a phrase you specified is recognized (I.E. it matches one of the phrases you specified), that phrase will be stored in a text variable with the name you specified in the "Text Variable" field.
If a different phrase is spoken and the "Continue on any Speech" option is enabled, the text variable with the name you specified in the "Text Variable" field will instead be set to the literal text value "@invalid".
If a different phrase is spoken and the "Continue on any Speech" option is not enabled, the command will continue waiting (for the duration of the value specified in the "Timeout" option, or indefinitely if that value is 0) until one of the phrases you specified is recognized.

In either case, the unrecognized phrase you speak does not reach the condition. That is not how the "Wait For Spoken Response" action works.


If you want to achieve that type of "dynamic" response within a command, you'd need to use the dictation mode instead.

E.G.
Code: [Select]
Start Dictation Mode (Clearing Dictation Buffer)
Start Loop While : [{DICTATION}] Equals ''
End Loop
Stop Dictation Mode
Begin Text Compare : [{DICTATION}] Contains 'parking'
    Write [Green] '"parking" was spoken' to log
Else
    Write [Red] '"parking" was not spoken' to log
End Condition

tgsnet

  • Newbie
  • *
  • Posts: 8
Re: How does "Contains" actually work?
« Reply #4 on: May 29, 2021, 06:03:45 PM »
Thanks for the thorough explanation I appreciate it.

Also thank you for understanding what I was looking to accomplish and pointing me in the appropriate direction.