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,
"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:
<?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}&&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}&&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.