Author Topic: Changing options  (Read 6530 times)

0 Members and 2 Guests are viewing this topic.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Changing options
« on: April 20, 2014, 05:55:42 PM »
I know for the time being VC support changing just 2 options ... so I am trying to come with a work around what I need now is to replace the prefix in the options ....

the idea, read options.xml ... replace option line ... write file ... do full restart ...

however again I am failing with string manipulation  :bonk , I tried both results.replace and results.regexreplace



When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Changing options
« Reply #1 on: April 20, 2014, 06:27:41 PM »
Why do you want to change the prefix?

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Changing options
« Reply #2 on: April 20, 2014, 08:08:25 PM »
In the setup I am doing I need to use prefix all the time to reduce false positives ( using kinect mic)
And I would like to add different assistants ....
So I go
Niles let me speak with Amy
Vc changes tts voice to Amy
And changes prefix to Amy ....

So next command will be

Amy: turn off the lights ... And Amy answers
Rather than saying Niles turn if the lights and the confirmation comes with a female voice
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Changing options
« Reply #3 on: April 20, 2014, 08:48:28 PM »
If you want to change the prefix you will have to force VC to rebuild all groups of commands from scratch.  It seems like a rather heavy handed approach, and it seems that you are only making the program harder to use without adding any functionality.

In order to achieve what you want, you probably don't really need to change the prefix.  I think it would be better to either assign different prefixes to different groups of commands, or use multiple global prefixes simultaneously.

Assuming that you want to go ahead and do this anyway, you should first be ready to wait a considerable amount of time for the rebuild to complete whenever you want to change the global prefix.  Assuming you decide to do it you will first need to figure out what you are doing (hint you can probably just use replace, or if you want to use regex you should look into how to use regex paterns, and pay particular attention to matching spaces with \s).  Then you will need to delete all the compiled files in the srgs folder in order to force VC to rebuild everything when it restarts.

Of course none of this is necessary to change the TTS voice.
« Last Edit: April 20, 2014, 08:51:09 PM by jitterjames »

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Changing options
« Reply #4 on: April 20, 2014, 08:50:43 PM »
To assign different prefixes to different groups, see: http://voxcommando.com/mediawiki/index.php?title=Groups

And if you decide you want to have more than one global prefix (though obviously it's a bad idea to have more than a couple because it could increase the chance of false positives), separate them with commas. http://voxcommando.com/mediawiki/index.php?title=Options#Prefix_Mode
« Last Edit: April 20, 2014, 09:25:44 PM by jitterjames »
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: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Changing options
« Reply #5 on: April 20, 2014, 08:56:02 PM »
Oh, and by the way, you started this thread talking about the VC.SetOption action...  Changing the prefix using this method and then restarting would not make sense.  If you read the description of the action you will notice that it says:

"Temporarily overrides VoxCommando options.  These will not be saved and will return to previous values on restart. Only certain..."
« Last Edit: April 20, 2014, 10:31:47 PM by jitterjames »

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Changing options
« Reply #6 on: April 21, 2014, 02:31:36 PM »

or use multiple global prefixes simultaneously.

is there is a way to tell which prefix was used ? will it be part of (last spoken) ?

James: building time is not an issue for me, as for the time being I do not intend to use VC for media library ... more I am implementing it toward home automation and personal assistant ... where different personalities my not add functionality but will make it more fun ...

I am trying to figure out how replace work ... it fails when there is a space in the old string .... is there a comprehensive guide on how to use it with examples as well as for the regex functions ... they feel very powerful but some how my VB mind is not grasping the logic

Results.Replace  value=* name="PrefixString"  with value="{1}" name="PrefixString" where the star represents any number of characters ... the wiki do not mention if replace follow RegEx rules (the online page you pointed me to in another post)...


  Then you will need to delete all the compiled files in the srgs folder in order to force VC to rebuild everything when it restarts.


thanks .... this is valuable piece of info ...

Oh, and by the way, you started this thread talking about the VC.SetOption action...  Changing the prefix using this method and then restarting would not make sense.  If you read the description of the action you will notice that it says:

"Temporarily overrides VoxCommando options.  These will not be saved and will return to previous values on restart. Only certain..."

true .... then if I can make this work, we will have a way to change options permanently  ::)

 nime5ter: thank you for pointing these wiki entries ...

When Voice command gets tough, use hand gestures

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Changing options
« Reply #7 on: April 21, 2014, 03:01:01 PM »
I am trying to figure out how replace work ... it fails when there is a space in the old string .... is there a comprehensive guide on how to use it with examples as well as for the regex functions ... they feel very powerful but some how my VB mind is not grasping the logic

VC offers two different methods (actions) for replacing characters in a {LastResult} string -- Results.Replace or Results.RegExReplace. The latter is indeed more powerful and useful when necessary, but it's not necessary in your command example, so you would be better off with the regular Result.replace action and then a space is a space is a space.

Syntax for regular expressions is fairly language agnostic. As far as I know, it's much the same in Visual Basic -- so, to match a whitespace character you would use "\s" whether in C#, VB, or Python. (see the pattern matching chart here, for example: http://www.virtualsplat.com/tips/visual-basic-object.asp)

In VC's documentation and here on the forum, we've linked to the following cheat sheet quite often: http://www.mikesdotnetting.com/Article/46/CSharp-Regular-Expressions-Cheat-Sheet.

And if you search the forum for "regex" or "regular expressions" there is also a link to a youtube video tutorial that covers the basics.

In your initial description, you mention that you want to be able to say,
Quote
"Niles let me speak with Amy"
Vc changes tts voice to Amy
And changes prefix to Amy ....
...Rather than saying Niles turn if the lights and the confirmation comes with a female voice

If the only issue is fun factor and not functionality, why not just have 2 global prefixes (Niles, Amy) and a command along the lines of:
Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 1.9.2.2-->
<command id="222" name="Switch tts" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{1}&amp;&amp;Anna</ifParams>
    <then>
      <action>
        <cmdType>TTS.SetVoiceName</cmdType>
        <params>
          <param>Anna</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)==(B)</ifType>
    <ifParams>{1}&amp;&amp;Niles</ifParams>
    <then>
      <action>
        <cmdType>TTS.SetVoiceName</cmdType>
        <params>
          <param>Niles</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <phrase>Let me speak to</phrase>
  <payloadList>Anna, Niles</payloadList>
</command>

This accomplishes the same thing, without the complexity.

If you want to use Anna with certain command groups and Niles with others so that those commands won't be issued if you use the wrong name, you could either enable and disable specific command groups in the same command, or assign Anna as the prefix to some groups and Niles to other groups, instead of using two global prefixes.
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: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Changing options
« Reply #8 on: April 21, 2014, 03:19:06 PM »
I don't see how changing the prefix makes it more fun.  It just makes it harder to use since you need to remember who you are speaking to or your commands will be ignored.

But obviously it's up to you to use it how you want.  If you really want to do it this way, then you might just want to run a batch file that replaces your options.xml with another one that already has the new prefix, and deletes the srgs folder.  Call the batch file and then restart VoxCommando.

Or better yet have two VoxCommando installs, with different prefixes and switch between them.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Changing options
« Reply #9 on: April 21, 2014, 04:54:29 PM »
Thank you gays for the feedback
When Voice command gets tough, use hand gestures

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Changing options
« Reply #10 on: April 21, 2014, 05:01:03 PM »
I am a modern man, so I won't take offense to being called gay...  :biglaugh

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Changing options
« Reply #11 on: April 21, 2014, 05:26:13 PM »
Hahaha   ;D ;D ;D ... Typos ...
When Voice command gets tough, use hand gestures

pmdaniels73

  • $upporter
  • Sr. Member
  • *****
  • Posts: 118
  • Karma: 0
    • View Profile
Re: Changing options
« Reply #12 on: April 21, 2014, 11:17:37 PM »
I think in the video below might be what is trying to be accomplished. I could be wrong though.


jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Changing options
« Reply #13 on: April 22, 2014, 10:34:50 AM »
is there is a way to tell which prefix was used ? will it be part of (last spoken) ?

Yes.  That is correct.  The variable {LastSpoken} will include the prefix.  If you wanted to build logic into a command based on this you could use this variable.

Haddood

  • $upporter
  • Hero Member
  • *****
  • Posts: 688
  • Karma: 22
    • View Profile
Re: Changing options
« Reply #14 on: April 23, 2014, 05:41:51 PM »
I just discovered the reason that replace made me bang my head against the wall !!!! in fact it is internet explorer ... it switch the name and the value (see image) as opposed how things are really in the file (viewed using notepad) :biglaugh  :biglaugh  :biglaugh

When Voice command gets tough, use hand gestures