VoxCommando

Help and Support (Using VoxCommando) => VoxCommando Basics and Core Features => Topic started by: Cassan0va on June 09, 2016, 05:42:15 PM

Title: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 09, 2016, 05:42:15 PM
So what im trying to do (havnt found any CLEAR documentation on this) is that i drop a commando to get a response, random and fixed.

Example 1:

- Sarah, how are you today?
-- Im fine thank you; Could be better; Im a robot what do i know [Multiple responses that are used randomly]

Responses are either prerecorded WAVs or TTS, undecided.


Now i ask the same thing again shortly after, but since i already asked i would get a different response.

- Sarah, how are you today?
-- Same as last time you asked; Age hitting you that hard?; You already asked me that.

Example 2:

- Sarah, lock the door.
-- [Wait 5sec] Door is now locked.

Now i ask the same thing again shortly after, but since i already asked i would get a different response.

- Sarah, lock the door.
-- Door is already locked, would you like me to unlock it?

This triggers the next step which is a global [Yes] tied to this but it could also be tied to multiple phrases.
IE, Would you like me to unlock? Would you like me to turn on the lights? Would you like me to turn on the TV.

All of these questions should have the same simple answer of yes and no but tied to each phrase as a sub?

Thats basicly what im trying to do right now.
Another thing ive been thinking of is if after ive asked her to lock the door i can ask "Is the door locked".

Anyhow hope you understand what im getting at, currently working on homeseer setup to get this working properly, VA worked alright but this software seems like it was aimed towards what i want to achieve.

If you dont want to answer with examples atleast point me in the right direction.

Best regards Conny
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Kalle on June 10, 2016, 08:53:55 AM
Hi Conny and welcome to the Forum.


I think we can't give you the complete commands, but here is a start for your first example.


This command mirroring exact your example 1 - hard to explain each action.
It create also a event timer (clear answer) which will clear the last answer from your computer after 20 seconds otherwise it will answer you random "Same as last time you asked"; "Age hitting you that hard"; "You already asked me that!". The time start over and over again as long as the 20 seconds not past.
You can edit the timer action to your needs and also the text file.


I hope this will help you.


Copy and paste the following command group in your VC command tree - save the "randomAnswer.txt" file in your VC main folder.


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.9-->
<commandGroup open="True" name="example 1" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="351" name="how are you today" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="parameter (B) in the logic block contain a blank (space key) and is not empty!">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Var.lastAnswer}&amp;&amp; </ifParams>
      <then />
      <else>
        <action>
          <cmdType>VC.StopEventTimer</cmdType>
          <params>
            <param>clear answer</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Same as last time you asked | Age hitting you that hard | You already asked me that!</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>20</param>
            <param>clear answer</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>File.Read</cmdType>
      <params>
        <param>randomAnswer.txt</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegExSingle</cmdType>
      <params>
        <param>^(.*?)\r\n</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegExReplace</cmdType>
      <params>
        <param>^(.*?)\n</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.WriteLine</cmdType>
      <params>
        <param>randomAnswer.txt</param>
        <param>{LastResult}{CR}{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.GetLastText</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>lastAnswer</param>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.SetEventTimer</cmdType>
      <params>
        <param>15</param>
        <param>clear answer</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>how are you today</phrase>
  </command>
  <command id="352" name="clear event timer" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.StopEventTimer</cmdType>
      <params>
        <param>clear answer</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>lastAnswer</param>
        <param><![CDATA[ ]]></param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>clear answer</event>
  </command>
</commandGroup>
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 10, 2016, 09:25:10 AM
Hi Conny and welcome to the Forum.


I think we can't give you the complete commands, but here is a start for your first example.


This command mirroring exact your example 1 - hard to explain each action.
It create also a event timer (clear answer) which will clear the last answer from your computer after 20 seconds otherwise it will answer you random "Same as last time you asked"; "Age hitting you that hard"; "You already asked me that!". The time start over and over again as long as the 20 seconds not past.
You can edit the timer action to your needs and also the text file.


I hope this will help you.


Copy and paste the following command group in your VC command tree - save the "randomAnswer.txt" file in your VC main folder.


Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.9-->
<commandGroup open="True" name="example 1" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="351" name="how are you today" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="parameter (B) in the logic block contain a blank (space key) and is not empty!">
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{Var.lastAnswer}&amp;&amp; </ifParams>
      <then />
      <else>
        <action>
          <cmdType>VC.StopEventTimer</cmdType>
          <params>
            <param>clear answer</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Same as last time you asked | Age hitting you that hard | You already asked me that!</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.SetEventTimer</cmdType>
          <params>
            <param>20</param>
            <param>clear answer</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <action>
      <cmdType>File.Read</cmdType>
      <params>
        <param>randomAnswer.txt</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegExSingle</cmdType>
      <params>
        <param>^(.*?)\r\n</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegExReplace</cmdType>
      <params>
        <param>^(.*?)\n</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>File.WriteLine</cmdType>
      <params>
        <param>randomAnswer.txt</param>
        <param>{LastResult}{CR}{Match.1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.GetLastText</cmdType>
      <params />
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>lastAnswer</param>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>VC.SetEventTimer</cmdType>
      <params>
        <param>15</param>
        <param>clear answer</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>how are you today</phrase>
  </command>
  <command id="352" name="clear event timer" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>VC.StopEventTimer</cmdType>
      <params>
        <param>clear answer</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>lastAnswer</param>
        <param><![CDATA[ ]]></param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>clear answer</event>
  </command>
</commandGroup>

Wow thanks a bunch, already starting to feel that the switch over here was the right one :)
Really quick turn around and simple to edit, just have to study it abit to figure out what each bit does.

Any databank with examples like that one you just posted?
If not it might be an idea so people dont have to reinvent the wheel :)
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 10, 2016, 09:34:38 AM
Any ideas to the Global yes problem?

IE:
-Lock the door.
-- Door is locked
-Lock the door.
-- Door is already locked would you like to open it?
-Yes [This here could become a problem unless its tied to a specific set of phrases or phrase ((it only recognize this yes in combination with a specific phrase?))]
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Kalle on June 10, 2016, 10:26:38 AM
Yes I have a lot of ideas to do this - I will take a look on it later.
I know VC need a bit of learning how things work, but we have a lot of video tutorials and also a fantastic wiki documentation.


http://voxcommando.com/mediawiki/index.php?title=Main_Page
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 10, 2016, 10:54:15 AM
Yes I have a lot of ideas to do this - I will take a look on it later.
I know VC need a bit of learning how things work, but we have a lot of video tutorials and also a fantastic wiki documentation.


http://voxcommando.com/mediawiki/index.php?title=Main_Page

Will do that straight away thanks :)
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Kalle on June 10, 2016, 11:57:14 AM
I've a question about the door lock: Which command do you use to lock/unlook the door (sending a http request?)? It would be nice to get a response from the door lock, to be sure the command has worked. Maybe we can request the state from the door lock  or the door lock send an event - is this possible?


This would make a lot of things easier to create. We have (for example) the Vera HA plugin in VC, maybe your HA works in a similar way.


Your second example demonstrate not really how HA works, because VC doesn't know when the door is unlocked by hand or maybe the light was turn on by hand  ::hmm



Title: Re: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 10, 2016, 03:17:59 PM
I've a question about the door lock: Which command do you use to lock/unlook the door (sending a http request?)? It would be nice to get a response from the door lock, to be sure the command has worked. Maybe we can request the state from the door lock  or the door lock send an event - is this possible?


This would make a lot of things easier to create. We have (for example) the Vera HA plugin in VC, maybe your HA works in a similar way.


Your second example demonstrate not really how HA works, because VC doesn't know when the door is unlocked by hand or maybe the light was turn on by hand  ::hmm

The idea is to get it to work in VA, then have VA read a state from the scraper in homeseer as a URL.
Well in theory, have yet to test it.

The reason i want to get it to work in VC first is because it can be applied to a multitude of instances and not just a door.
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Kalle on June 10, 2016, 03:21:27 PM
Only a hint - VC has also scrape actions  ;)
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 10, 2016, 03:28:53 PM
Only a hint - VC has also scrape actions  ;)

Edit: I ment VC  :P

Yeah i know, thats one of the main reasons it caught my eye.
And now loads of stuff just keep popping up thats pretty awesome, its just completely differant from VA, while its a huge setback trying to get everything over to VC i think the positive ways over the negative.

Been looking over the wiki it feels like a huge slap in the face, if you are not sure what you are looking for its hard to find... Searching kinda works but still confusing.

Was looking at profile switching for the voice recognition, i guess its tied to the windows login profiles? I guess it has to be because of the training.

Best way is to setup new login profiles to get the speech recognition profiles and start training those then run the command inside VC to switch profile?
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Kalle on June 10, 2016, 04:26:26 PM
You looking for a command "action" to switch to a other profile?


If yes, take a look in the in the Wiki at Actions: http://voxcommando.com/mediawiki/index.php?title=Actions#SetProfile (http://voxcommando.com/mediawiki/index.php?title=Actions#SetProfile)

http://voxcommando.com/forum/index.php?topic=1482.msg12876#msg12876

Also a search here in the forum with: "set speech profile" or "train speech profile" will give you good results.
Yes I know, there are a lot of information in the Wiki - but VC need a bit of learning curve and I'm sure you will find out fast how all the things work in VC.
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 10, 2016, 05:02:34 PM
found the command, setprofile. Yeah i tried looking over those topics, but as i said it links to the windows profiles right?
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Kalle on June 10, 2016, 05:11:35 PM
yes, that is correct - it use the windows speech profiles.
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 10, 2016, 06:44:08 PM
The way the door thing was done in VA was something like this.

Quote
"Lock the Door".
If  [doorstatus] = 1
run "toggle door" command
Set [doorstatus] = 2
End Condition - Exit when condition met
If [doorstatus] = 2
Run "Door is already locked" sound file.
End Condition - Exit when condition met


"open the door"
If [doorstatus] = 1
run "Door is already unlocked" sound file
End Condition - Exit when condition met
If [doorstatus] = 2
run "toggle door" command
Set [doorstatus] = 1
End Condition - Exit when condition met

Not the exact code but the gist of it, cant figure out how to recreate it here
Title: Re: Commands and Responses - I just moved over from VA.
Post by: nime5ter on June 11, 2016, 05:32:29 AM
There is no Homeseer plugin in VC, so you'll have to handle some of the black box magic yourself (if it's possible with Homeseer).

For most users, it's easier to start learning VC's command structure, terminology, and UI by installing a standard configuration and exploring the existing commands for a while, rather than trying to build a customized command set from nothing.

Are you using HS2 or HS3 or is there something else now?
HS2: http://voxcommando.com/forum/index.php?topic=1405.msg12143
HS3: http://voxcommando.com/forum/index.php?topic=1395.msg12019#msg12019

Either way, it will be something like:

1. Scrape Homeseer to get status information back about the lock state.
2. Evaluate the information that comes back using a regular expression (http://voxcommando.com/mediawiki/index.php?title=Actions#RegEx) followed by one or more logic blocks (http://voxcommando.com/mediawiki/index.php?title=Logic_Block). You can use 2 logic blocks if you like, as you describe above.

Hint: Use the action VC.StopMacro (http://voxcommando.com/mediawiki/index.php?title=Actions#StopMacro) to exit the command when condition is met in your logic block, but before the last line of the command.

The get status and set door status will require knowing the correct URL, which is not determined by VC. This will require consulting the documentation for whatever Homeseer http querying solution you're using.

In general, it's a good idea in VC to become familiar with the terminology used in the program (a command is made up of a set of actions). The command is the macro as a whole, in other words.

And to spend some time scanning core actions and relevant plugin actions, which can be done within the program via the Action Selection Tree (http://voxcommando.com/mediawiki/index.php?title=Action_Selection_Tree), or in the wiki.

Core actions page of the wiki: http://voxcommando.com/mediawiki/index.php?title=Actions
Plugin actions are found on individual plugin pages.

Also very important: get familiar with VC variables, such as {LastResult}.
http://voxcommando.com/mediawiki/index.php?title=Variables

Generally we use the TTS  (http://voxcommando.com/mediawiki/index.php?title=Plugin_TTS)(or TTSMS) plugins for text-to-speech announcements. If you want to record sound files for every announcement, that's up to you. There are various actions in VC for playing audio files.

Eventually, you may want to learn how to integrate payloads and payload XML (http://voxcommando.com/mediawiki/index.php?title=Payloads) so that you don't have to duplicate the same command over and over for each device and each device state. But I would start more simply and work up to that.
Title: Re: Commands and Responses - I just moved over from VA.
Post by: nime5ter on June 11, 2016, 06:20:10 AM
Along the lines of:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.9-->
<command id="132" name="open door lock" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This command assumes that Homeseer returns a value of 0 when &quot;unlocked&quot; and 1 when &quot;locked&quot;. It also assumes that if the value isn't 0, it will be 1. But you don't need to use the &quot;else&quot;. You could use multiple &quot;if&quot; cases instead, as in your pseudo-code. Just leave the Else section empty and add more logic blocks as desired.">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>http://(HS3 URL)/HomeSeer_REST_API.aspx?function=getdeviceinfo&amp;param1=(DEVICE NAME OF YOUR LOCK)</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>value="(\d)"</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{Match.1}&amp;&amp;0</ifParams>
    <then>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>The door is already open.|No need. Your door was not locked.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>Scrape</cmdType>
        <params>
          <param>(URL to open the door lock)</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>TTS.Speak</cmdType>
        <params>
          <param>OK. I'm unlocking the door.|Unlocking door.|Your door is now open.</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <phrase>Open the door, Unlock the door</phrase>
</command>
Title: Re: Commands and Responses - I just moved over from VA.
Post by: Cassan0va on June 11, 2016, 06:13:32 PM
You are prob right, gonna play around with kodi and do some more house hold tasks. Read the news, time, events, calendar etc.

Just to grasp VC, just feels abit overwhelming.

Well recording is an option, wanted the feel of more natural speaking or even AI sort.
Title: Re: Commands and Responses - I just moved over from VA.
Post by: nime5ter on June 11, 2016, 09:13:19 PM
I don't know whether you want English feedback or another language, but some of Ivona's voices are quite good  (no TTS voice is perfect).

Be sure to get a SAPI5 voice. Text Aloud sells individual Ivona SAPI5 voices (http://www.textaloud.com/swedish.shtml) for US$45, which is not a terrible price.

Once you've installed the voice, it should show up in the TTS plugin window (http://voxcommando.com/mediawiki/index.php?title=TTS_settings) the next time you open VC.

You can also experiment with adjusting the voice synthesis rate (speed) (http://voxcommando.com/mediawiki/index.php?title=Plugin_TTS#SetRate), pitch, and so on if you are not happy with the default settings.

(e.g. http://voxcommando.com/forum/index.php?topic=2138.msg18558#msg18558)

You could always use TTS for some situations but record some of the feedback, of course.

I cannot stop you from feeling overwhelmed, but I think if you are not in a rush to finish your ambitious project you will have more fun with it.

Speaking only for myself -- finding a solution to a challenging problem and learning new ways to use the program is pretty much my favourite hobby.