Author Topic: Search a in b  (Read 1097 times)

0 Members and 1 Guest are viewing this topic.

LightsOn

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Search a in b
« on: July 08, 2019, 02:28:43 AM »
Hi all,

Struggling with this one but feel it will have a simple answers.

I have a payload and I want to search it for 'b'.

The search is 'a' - this is payload:diction. So I speak 'search for x' where x is anything I choose.

I want it to search for x ('a') in payload list 'b' and if found do x and if not do y.

Similar example is 'Do we have the number 5 in a list of 1 to 10' = yes. 'Do we have number 12 in a list of 10 = no.'

Any advice is welcomed.

Thank you.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Search a in b
« Reply #1 on: July 08, 2019, 12:06:40 PM »
Sorry.  I can see that you tried to be thourough in the asking of your question but I still find it confusing and hard to understand exactly what you are trying to achieve.

I am guessing that you want to search for some word and that you are using a payload dictation to let the user specify what word you want to search for.  Correct me if that part is wrong.

But then I don't know where you want to search to see if this word exists.

In your "similar example" you are are searching in some list of numbers, but where is this list of numbers stored, or how is it defined or  accessed?  Are you always searching in the same place or does the user's voice command somehow specify what data source is to be searched?

It might help if you tell me exactly what you are trying to do instead of creating similar examples.
« Last Edit: July 08, 2019, 01:43:34 PM by jitterjames »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Search a in b
« Reply #2 on: July 08, 2019, 02:18:32 PM »
Like James, I'm not 100% sure if I understood you, but I *think* you're trying to do something like this?


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.4.7-->
<command id="454" name="Search my list for {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>VC heard: {1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PayloadXML.GetValue</cmdType>
    <params>
      <param>payloads\produce.xml</param>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>LastActionSuccess</ifType>
    <ifParams>&amp;&amp;</ifParams>
    <then>
      <action>
        <cmdType>OSD.AddText</cmdType>
        <params>
          <param>Found: {LastResult}</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>OSD.AddText</cmdType>
        <params>
          <param>{1} was not found in the Produce payload file</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>Search my list for</phrase>
  <payloadDictation>payloadDictation: Regular</payloadDictation>
</command>

The example above does the following:
1. Voice command: Search "my list" for {payload based on payload dictation}.
2. Command searches a payload xml file called "produce.xml" (see attached*) to see if the understood phrase is found.
3. If that phrase is found, returns the value from the payload XML file.
4. If phrase not found, my command indicates that it wasn't found.

If one wanted to execute 2 different commands depending on the if/else logic, one could use event triggers (VC.TriggerEvent) in each case to trigger 2 separate commands.

There are other ways to do this as well.

I admit I may be misunderstanding your aim but maybe this starting point can help the discussion progress.

*The file path in the command points to the produce.xml file stored in the payloads folder of my VC directory.


« Last Edit: July 09, 2019, 08:10:02 AM by nime5ter »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

LightsOn

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Search a in b
« Reply #3 on: July 09, 2019, 04:39:00 AM »
Hi Both,

Thank you for taking the time to help me.  Firstly - apologies - I had thought my example was clear but I agree I think in my attempt to make things clear I have done quite the opposite.

The goal is I have a list of radio stations in a payload.  This Payload is dynamically created every so often - so stations listed change.  As such I wanted to be able to "search" for if a station existed.  Playing desired station is easy enough.

nime5ter, your example is as good as what I need. Thank you.  I was so close in my own attempts.  I (perhaps oddly) could not see how to obtain the value of a <Return> but can now see that you pass the action, then use {LastResult}, this is now clear.  I also tried PayloadXML.GetPhrase myself but see now that I need to pass PayloadXML.GetValue to be then able to use PayloadXML.GetPhrase.  I seemingly was staring at the answers but just was not paying enough attention!

This small help has really got me up and running - thank you.

My code now looks like the below - admittedly this is a altered version of the example by nime5ter but as good as there.

Code: [Select]
            </command>
            <command id="454" name="Search my list for {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
                <action>
                    <cmdType>PayloadXML.GetValue</cmdType>
                    <params>
                        <param>Payloads\produce.xml</param>
                        <param>{1}</param>
                    </params>
                    <cmdRepeat>1</cmdRepeat>
                </action>
                <if ifBlockDisabled="False" ifNot="False">
                    <ifType>LastActionSuccess</ifType>
                    <ifParams>&amp;&amp;</ifParams>
                    <then>
                        <action>
                            <cmdType>PayloadXML.GetPhrase</cmdType>
                            <params>
                                <param>Payloads\produce.xml</param>
                                <param>{LastResult}</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                        <action>
                            <cmdType>OSD.ShowText</cmdType>
                            <params>
                                <param>Found: {LastResult}</param>
                                <param>5000</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </then>
                    <else>
                        <action>
                            <cmdType>OSD.ShowText</cmdType>
                            <params>
                                <param>{1} was not found in the payload file</param>
                                <param>5000</param>
                            </params>
                            <cmdRepeat>1</cmdRepeat>
                        </action>
                    </else>
                </if>
                <phrase>Search my list for</phrase>
                <payloadDictation>payloadDictation: Regular</payloadDictation>
            </command>
        </commandGroup>


What I am finding now however is that it does not always trigger off the back of the phrase so as such I may need to simply improve the phrase used?  If I search for something I know is there it always works.  If I search for something random it some times does and sometimes does not trigger the event to search if it is present or not.  Any thoughts around this?  Am I right in thinking I should just play with the phrase used?

I am using TellVox at present and not my actual voice however - not sure if this makes any difference?  I assume not.

Thank you in advance.


Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: Search a in b
« Reply #4 on: July 09, 2019, 07:38:54 AM »
Hi LightsOn,


Quote
I am using TellVox at present and not my actual voice however - not sure if this makes any difference?  I assume not.

This make the difference - Tellvox send exactly what you have typed in the "send field" and VC can only execute a command, which contain exact this text as phrase.

You can see this effect in the VC history window which generate a orange message (hover your mouse over the message) and you will see the info "Error: Unknown voice command".

In other words - you have to use your voice for testing this command.
« Last Edit: July 09, 2019, 08:39:27 AM by nime5ter »
***********  get excited and make things  **********

LightsOn

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Search a in b
« Reply #5 on: July 09, 2019, 07:43:49 AM »
Hi Kalle,

Okay thank you.

So it does make a difference then.  As such I shall try my implementation later today and report back if I get better results.

Thank you.

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: Search a in b
« Reply #6 on: July 09, 2019, 08:39:20 AM »
sorry for the text format issue  :bonk


Thanks nime5ter
***********  get excited and make things  **********

LightsOn

  • Jr. Member
  • **
  • Posts: 18
  • Karma: 4
    • View Profile
Re: Search a in b
« Reply #7 on: July 09, 2019, 08:47:13 AM »
Appreciate the details - its helps me and each day my set up is getting better and better.  Thank you.