Author Topic: 3 VC questions  (Read 2999 times)

0 Members and 1 Guest are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
3 VC questions
« on: May 21, 2014, 03:06:08 AM »
1. I am looking for a way to measure the time lapsed since last successful recognition and I have no idea where to start ... any ideas appreciated

2. Is there is a way to query VC mode (off, stand by, on) ?

3. When I use scrape.xml, is there is a way to read the inner nodes ? it seems all values comes concatenated
« Last Edit: May 21, 2014, 04:45:45 AM by Haddood »
When Voice command gets tough, use hand gestures

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: 3 VC questions
« Reply #1 on: May 21, 2014, 07:54:28 AM »
1. I think it is possible with a logic block and VC.SetEventTimer, but at the moment I have no idea how.  ::hmm

2. Yes, VC generate a event for each mode like VC.On/VC.Standby and VC.Off, so you can work with this events
As example you can write the current mode on a webserver or send the event to Eventghost ...

3. I think you must use the Scrape.XML action: http://voxcommando.com/mediawiki/index.php?title=Actions#XML


I hope this will help a bit.
« Last Edit: May 21, 2014, 08:55:20 AM by Kalle »
***********  get excited and make things  **********

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #2 on: May 21, 2014, 11:10:53 AM »
1. I am looking for a way to measure the time lapsed since last successful recognition and I have no idea where to start ... any ideas appreciated

2. Is there is a way to query VC mode (off, stand by, on) ?

3. When I use scrape.xml, is there is a way to read the inner nodes ? it seems all values comes concatenated

1: why ?

2: see Kalle's suggestion.  Again, why?

3: Scrape.XML is not very sophisticated.  For anything complicated please just use scrape and results.regex.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: 3 VC questions
« Reply #3 on: May 21, 2014, 11:29:26 AM »
Just to clarify -- In our "getting support"/"forum rules" documentation, we mention that an important part of posing questions on the forum is to "describe the goal, not the step".  (http://voxcommando.com/mediawiki/index.php?title=Getting_support#When_You_Ask)


Knowing the "why" right of the bat tends to save everyone a lot of time, in that there are different strategies one could use to solve a problem depending on the objective.

Without actually knowing why, we're more likely to suggest technically correct answers that are nonetheless unhelpful and potentially frustrating.
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)

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: 3 VC questions
« Reply #4 on: May 21, 2014, 05:27:03 PM »
1. Part of a redundant presence detection ... and conditional responses to make it more humane :)
2. it has to do with reseting the led lights on serial port to what their state before blinking for low confidence or ignoring recognition ...
3. Rogers ... however scrape.xml much faster (or at least this is how it was in 1.9.5.0 ... will test with the 1.9.5.1) ... it will be great if inner nodes cane be scraped or be assigned matches.x.y

thank you guys for all the responses


1: why ?

2: see Kalle's suggestion.  Again, why?

3: Scrape.XML is not very sophisticated.  For anything complicated please just use scrape and results.regex.
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #5 on: May 21, 2014, 06:34:15 PM »
3:  Scape xml is faster?  That is surprising to me. I guess I would need to see what you are scraping, and maybe your command to see how you are doing it.  Then I might be able to suggest something.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #6 on: May 21, 2014, 06:48:32 PM »
Maybe this example will help you, maybe not:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.1-->
<command id="257" name="test xml method" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>http://www2.radioparadise.com/now_playing.xml</param>
      <param>album</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{Match.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: 3 VC questions
« Reply #7 on: May 22, 2014, 02:41:08 PM »
1. I think it is possible with a logic block and VC.SetEventTimer, but at the moment I have no idea how.  ::hmm

2. Yes, VC generate a event for each mode like VC.On/VC.Standby and VC.Off, so you can work with this events
As example you can write the current mode on a webserver or send the event to Eventghost ..

I hope this will help a bit.

kalle
for 1 can you explain a bit more.... as far as know no event fired with positive recognition ... if it exist it will be perfect. Record time then subtract ...

for 2 ... I use these events to modify my leds status ... however if I change leds due to low confidence ... there is no way to know which one it was before .. even in the case of a VFD (screen) or arduino, say VFD showing: VC in stand by ... you say something and VFD show low confidence so you know it was not accepted ... how do we know to set screen back to Stand by and not ON

James:

3. The xml file I want to scrape is:
https://montreal.bixi.com/data/bikeStations.xml

I am posting 2 commands, one works with scrape only and one with scrape.xml the first work but takes lots of time to clean the xml ... the second works but data come concatenated ... now the work around I am fetching the data using hard coded {match.x} it is working but the moment they add or remove a station it won't work anymore as I will false results. Ideally I can scrape.xml the node station, with the ID passed as variable ... then sub matches will give the required fields

Again thanks guys for all the feedback

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.1-->
<command id="1003" name="Bixi info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <params>
      <param>.*&lt;id&gt;381&lt;/id&gt;</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <params>
      <param>&lt;/nbBikes&gt;.*</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.TriggerEvent</cmdType>
    <params>
      <param>feedback</param>
      <param>{LastResult}</param>
      <param>2</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
</command>

Second one:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.1-->
<command id="999" name="Bixi info" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
      <param>name</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>At {Match.345}</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
      <param>nbBikes</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>There is {Match.345} bikes near home</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
      <param>nbEmptyDocks</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{LastResult} and  {Match.345} docks</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
      <param>name</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{LastResult} and at {Match.271}</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
      <param>nbBikes</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{LastResult} there is {Match.271} bikes</param>
    </params>
    <cmdRepeat>0</cmdRepeat>
  </action>
  <action>
    <cmdType>Scrape.XML</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
      <param>nbEmptyDocks</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{LastResult} and {Match.271} docks at the metro.</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>VC.TriggerEvent</cmdType>
    <params>
      <param>feedback</param>
      <param>{LastResult}</param>
      <param>2</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>Bixi info</phrase>
  <event>Bixi info</event>
</command>

When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: 3 VC questions
« Reply #8 on: May 22, 2014, 03:07:14 PM »
How about something like this?
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.1-->
<command id="1158" name="What's the status of {1} station" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>&lt;id&gt;{1}&lt;.*?&lt;name&gt;(.*?)&lt;.*?&lt;nbBikes&gt;(.*?)&lt;.*?nbEmptyDocks&gt;(.*?)&lt;</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>Station: {Match.1.1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>No. bikes: {Match.1.2}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.AddText</cmdType>
    <params>
      <param>No. empty docks: {Match.1.3}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>What's the status of</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">bixi.xml</payloadFromXML>
  <phrase>station</phrase>
</command>

I have a payload xml file with id associated with 'friendly' station name (attached). This executes very quickly.

... There are then various solutions for passing the relevant data to your feedback command.
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)

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: 3 VC questions
« Reply #9 on: May 22, 2014, 03:34:50 PM »
The following generates a payload xml file with all station names associated with their station IDs.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.1-->
<command id="1161" name="generate bixi xml" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Scrape</cmdType>
    <params>
      <param>https://montreal.bixi.com/data/bikeStations.xml</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>&lt;id&gt;(.*?)&lt;.*?&lt;name&gt;(.*?)/(.*?)&lt;</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PayloadXML.Clear</cmdType>
    <params>
      <param>bixi.xml</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>PayloadXML.AddPair</cmdType>
    <params>
      <param>bixi.xml</param>
      <param>{Match.{i}.1}</param>
      <param>{Match.{i}.2} and {Match.{i}.3}</param>
      <param>True</param>
    </params>
    <cmdRepeat>{#M}</cmdRepeat>
  </action>
  <phrase>generate bixi xml</phrase>
</command>

I've replaced the slash (/) that they use in their station names with the word "and", to improve VC's recognition of each intersection.
« Last Edit: May 23, 2014, 10:53:49 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)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #10 on: May 22, 2014, 04:08:06 PM »
for 2 ... I use these events to modify my leds status ... however if I change leds due to low confidence ... there is no way to know which one it was before

You have access to the last mode via the events.  Now all you need to do is store the value in a variable.  Then you can use the variable later on, in whatever commands.  I don't know if you are using python or trying to only use VC commands.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.5.1-->
<commandGroup open="True" name="store current vc mode" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="216" name="store current vc mode" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>VCMode</param>
        <param>{LastEvent}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <event>VC.On</event>
    <event>VC.Off</event>
    <event>VC.Standby</event>
  </command>
  <command id="223" name="show current vc mode" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{Var.VCMode}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
  </command>
</commandGroup>

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #11 on: May 22, 2014, 04:16:00 PM »
Beautiful work Nime5ter!!!


Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2319
  • Karma: 47
    • View Profile
Re: 3 VC questions
« Reply #12 on: May 22, 2014, 04:22:57 PM »
Quote
kalle
for 1 can you explain a bit more.... as far as know no event fired with positive recognition ... if it exist it will be perfect. Record time then subtract ...

for 2 ... I use these events to modify my leds status ... however if I change leds due to low confidence ... there is no way to know which one it was before .. even in the case of a VFD (screen) or arduino, say VFD showing: VC in stand by ... you say something and VFD show low confidence so you know it was not accepted ... how do we know to set screen back to Stand by and not ON

1. If you take a look in your tree editor, there is a group named "Vox Commands". In this groups are stored commands like "listen", "don't listen", "vox off" ...
If you click at the plus next to the "don't listen" command, you will see the phrases for the command, followed by an event "VC.Standby" and the same for the commands "Listen" and "Vox-Off". So far I know this commands are generate events as standard in each VC configuration. If you change the VC mode, you will see a event in you history windows (see attached picture).
In the commands itself you can insert a action which send data over UDP,TCP or whatever you want to a other programm like Eventghost or to your home automation which switch a LED in different colours.

Kalle

nime5ter was faster  ;)
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: 3 VC questions
« Reply #13 on: May 22, 2014, 04:36:33 PM »
nime5ter was faster  ;)

:)

I only tried to provide some assistance for ways to handle the regex question. I leave the rest to you and your compadres. Teamwork!
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)

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: 3 VC questions
« Reply #14 on: May 23, 2014, 03:54:17 AM »
nime5ter,

I think we should call you RegEx Queen ... very neat solution and exactly what I was looking for ... this morning started to experiment with scrape and RegEx but I am still a toddler when it comes to that.

James,
Interesting ... for some unknown reason I am reluctant to use variables, maybe that goes back to my Sinclair PC, where every bytes counts  :biglaugh ....

Kalle,
thanks for the explanation however I think I wasn't clearin explaining the issue. my thing was not controlling the leds this is done using VC and a small driver for com port. it was more to fix the led color to VC state after I change it due to low confidence or rejection

a million thanks  again guys... you make VC experience lots of fun...
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #15 on: May 23, 2014, 09:28:21 AM »
James,
Interesting ... for some unknown reason I am reluctant to use variables, maybe that goes back to my Sinclair PC, where every bytes counts  :biglaugh ....

Didn't you get the 2 kilogram 16K memory expansion brick?

My greatest fear was turning it off.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #16 on: May 26, 2014, 06:00:54 PM »
2. Is there is a way to query VC mode (off, stand by, on) ?

You can use the variable {Status}.  This variable has been available for some time, but I forgot to put it into the auto-complete, the parameter helper buttons, or to document it!  I will do that for the next version but you should already be able to use it in your actions with 1.9.5.1.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: 3 VC questions
« Reply #17 on: May 26, 2014, 06:04:31 PM »
You can use the variable {Status}.  This variable has been available for some time, but I forgot to put it into the auto-complete, the parameter helper buttons, or to document it!  I will do that for the next version but you should already be able to use it in your actions with 1.9.5.1.

Sweeeeeeeet !!!!!   ::wiggle ::wiggle
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #18 on: May 26, 2014, 06:23:44 PM »
I went to put it in the wiki and it is already there!  :bonk

http://voxcommando.com/mediawiki/index.php?title=Variables#.7BStatus.7D

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: 3 VC questions
« Reply #19 on: May 26, 2014, 06:24:35 PM »
 :biglaugh :biglaugh :biglaugh :biglaugh :biglaugh

I just checked it and it works !!!
When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 2009
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: 3 VC questions
« Reply #20 on: May 26, 2014, 06:26:31 PM »
I went to put it in the wiki and it is already there!  :bonk

http://voxcommando.com/mediawiki/index.php?title=Variables#.7BStatus.7D

Almost like some kind of mysterious online fairy magically documents your work while you're not looking.
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)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7713
  • Karma: 116
    • View Profile
    • VoxCommando
Re: 3 VC questions
« Reply #21 on: May 26, 2014, 06:31:35 PM »
INCONCEIVABLE!!