Attached to this post are 2 files. One is a payload XML file (contact list.xml). The other is a simple text file (Einstein_quotes.txt).
Please download them.
- Put the payload XML file in the "payloads" subfolder within your VoxCommando folder.
- Put the text file directly in the VoxCommando folder.
- Copy the entire command group below into your command tree. Save and exit your tree.
- It's also a good idea to enable the History window (check the "history" box in the main UI).
- Then go back in to the command tree ("Edit") so you can start to explore these commands.
The commands are numbered. Start with the first one.
Look at the command phrasing in the tree. Then double-click to open up the command and look at the macro there.
Issue the voice command, see what happens.
Once you feel you understand that command, move on to the next command. Et cetera.
When you get to Command 4, which introduces payload XML files, start by double-clicking on the payload XML file in your command tree.
Choose "Open/Edit" so that you can view what's in that file. Take note of the phrases. If you want, you can add some of your own and save the changes.
Then go look at the command's macro so that you can see how the payload file is being used.
Issue the voice command a few times (now that you know the phrases that are in the payload xml file).
Make sense? Good. Move on to the next command.
If you spend half an hour going through these commands one by one sequentially, at the end you will have learned fundamentals that you can apply to other situations.
And you will also have learned several different ways to handle your current random TTS response problem.
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.1.4-->
<commandGroup open="True" name="VoxCommando basics" enabled="True" prefix="" priority="0" requiredProcess="" description="">
<command id="177" name="1. Set last result" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="The action description says exactly what Results.SetLastResult does. If this command does not make sense, roll over the action field or click the "magic wand" to see the action description. If you don't understand what the {LastResult} variable in VC is, see the variables page of the wiki.">
<action>
<cmdType>Results.SetLastResult</cmdType>
<params>
<param>I'm now setting the content of the 'last result' variable in VC.</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Set last result</phrase>
</command>
<command id="178" name="2. Learn how to use one payload" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This voice command includes a PAYLOAD LIST of people's names. When we say the voice command, "Say hello to X", X is the PAYLOAD. In other words, we are giving the command ONE PAYLOAD that can be used in the command. That is the {1}.">
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>Hello {1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>Hello {1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Say hello to</phrase>
<payloadList>John, Bob, Dan, Maggie, Linda</payloadList>
</command>
<command id="179" name="3. Learn how to use two payloads" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This voice command uses TWO PAYLOADS. 
1. A PAYLOAD RANGE of numbers ranging from 2 to 20. 
2. A PAYLOAD LIST of words.
So the {1} will be replaced with the number we say, and the {2} will be replaced by the word we choose.">
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>You asked me to show you: {1} {2}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>You asked me to show you: {1} {2}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Show me</phrase>
<payloadRange>2,10</payloadRange>
<payloadList>apples, bananas, spoons, forks</payloadList>
</command>
<command id="180" name="4. Learn how a payload XML file works" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="This command uses just ONE PAYLOAD. The payload will come from a list of payload VALUES stored in a PAYLOAD XML file.

A payload XML file is just a reference table with two columns. Usually we use a "value/phrase" payload XML file, where a friendly phrase is associated with a value that the command will need. That way, in our voice command, we can say the friendly phrase, and VC will understand that it should retrieve the associated value. In this case, the friendly phrase is our contact's name. The value is that contact's phone number.
If the payload XML is the only payload we're using in our command, then:
The value stored in the table is accessed using {1}.
Sometimes we may also need to get the phrase, not just the value. The phrase is known as the "friendly payload". We can access it using the syntax: {PF.1}">
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>Sure. The phone number is: {1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Do you have the phone number for</phrase>
<payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\contact list.xml</payloadFromXML>
</command>
<command id="131" name="5. Using payload XML in the macro, but not the voice command" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Usually we want to access payload XML values by asking for something specific in our voice command. But that's not the only way we can use them. These files are convenient ways to store information. And then we can retrieve that information at any time by "reading" the file within our macros. The action "PayloadXML.GetRandomP" is one of several actions that allow us to access data stored in a payloadXML file.">
<action>
<cmdType>PayloadXML.GetRandomP</cmdType>
<params>
<param>payloads\contact list.xml</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>Here is a random phrase: {Match.1}</param>
<param>5000</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Read me a random phrase from a payload XML file</phrase>
</command>
<command id="132" name="6. Another way to read text from a file" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="We can also read text from normal text files, not just payload XML files. Look up the action description for File.Read for more information.">
<action>
<cmdType>File.Read</cmdType>
<params>
<param>Einstein_quotes.txt</param>
<param>{1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>Line {1} says: {LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>TTS.SpeakSync</cmdType>
<params>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Read me line number</phrase>
<payloadRange>1,8</payloadRange>
</command>
<command id="188" name="7. Other interesting things you can do with text files" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="Here, instead of telling VC what line to read from the file, we use the random number generator to randomly select a line of text from the file. Again, see the variables page of the wiki for a description of the variable {Rnd.#.#}.">
<action>
<cmdType>File.Read</cmdType>
<params>
<param>Einstein_quotes.txt</param>
<param>{Rnd.0.8}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>Here's a random line: {LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Read me random line from my text file</phrase>
</command>
<command id="1491" name="8. Playing with a LastResult" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="We mostly perform regular expressions on {LastResult}. Here, we capture each phrase that's contained within "quotation marks". Each of them is stored as: {Match.1}, {Match.2}, etc.">
<action>
<cmdType>Results.SetLastResult</cmdType>
<params>
<param>"Hey there." "Aloha, what's up" "What do you want?" "Cheers, mate" "What's the story, morning glory?"</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegEx</cmdType>
<params>
<param>"(.*?)"</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>Random response: {Match.Rnd}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<phrase>Surprise me</phrase>
</command>
</commandGroup>