Author Topic: "how do you spell ...."  (Read 2747 times)

0 Members and 1 Guest are viewing this topic.

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
"how do you spell ...."
« on: November 24, 2014, 11:32:42 PM »
I'm trying to create a command for spelling so i can say "how do you spell {measuring}" {measuring} = payload dictation regular
then have it say "measuring, m e a s u r i n g"  and have an OSD with the word

i know that in order to get it to spell the word out well enough to be understood by tts, I need to add a semicolon and space after each letter  "m: e: a: s: u: r: i: n: g:"

i thought i could have vox right the word to a text file and then have it add the semicolon and space after each letter but after messing around with vox the only way i could think of do this would be to have a batch or python script do it for me but i don't know enough about batch to do it my self and i don't know python at all. so i thought i would look here to see if anyone had a better idea on how to get this to work


simply put
me :"how do you spell measuring"
vox: "meausuring, m e a s u r i n g" with OSD

any help would be great
thanks

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: "how do you spell ...."
« Reply #1 on: November 25, 2014, 08:41:32 AM »
Easy one if you know how to use RegEx!

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.0-->
<command id="374" name="how do you spell" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.SetLastResult</cmdType>
    <params>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <params>
      <param>(\w)</param>
      <param> $1 -</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.RegExReplace</cmdType>
    <params>
      <param>-$</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}</param>
      <param>8000</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>{1}, is spelled. {LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>how do you spell</phrase>
  <payloadDictation>payloadDictation: Regular</payloadDictation>
</command>

In the making of this command I noticed that there is a bug in the latest beta when you try to create a new PayloadDictation in a command.  :bonk

I will try to release a new version today with a fix.  If you copy and paste or load an old command it should still work normally.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: "how do you spell ...."
« Reply #2 on: November 25, 2014, 09:39:49 AM »
Since there's more than one way to skin a cat, here's my preferred solution:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.1-->
<command id="349" name="How do you spell {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>Results.RegEx</cmdType>
    <params>
      <param>(\w)</param>
      <param />
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Results.MatchConcat</cmdType>
    <params>
      <param> - </param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>OSD.ShowText</cmdType>
    <params>
      <param>{LastResult}</param>
      <param>7000</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>TTS.Speak</cmdType>
    <params>
      <param>{1}, is spelt, {LastResult}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase>How do you spell</phrase>
  <payloadDictation>payloadDictation: Regular</payloadDictation>
</command>

Take your pick. :)
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)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: "how do you spell ...."
« Reply #3 on: November 25, 2014, 11:27:09 AM »
wow thanks, they both work great and a lot easier then what i was thinking i would have to do, i knew someone would have a better way to do it then i was thinking

thanks again

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: "how do you spell ...."
« Reply #4 on: November 25, 2014, 12:36:50 PM »
Glad they meet your needs.

For VC users who may not be familiar with how regular expressions work, the above commands work as follows:

In each case, the word we want to spell is passed to the command (macro) as payload 1 --> {1} .

James's version:

1. He tells VC to make {LastResult} = {1}. This is needed for his next action, which only operates on the variable {LastResult}.

2. He tells VC to look for a particular regular expression pattern in {LastResult}, and to capture that pattern:
  - \w is RegEx speak for "any word character". Placing this in brackets is what tells VC to capture and store that pattern every time it is found.
 -  in the second parameter, he tells VC to replace each match of pattern "\w" with " (matched character)"+ " -"

(see http://voxcommando.com/mediawiki/index.php?title=Actions#RegExReplace)

3. In the third action, he's chosen to correct the minor problem of the last matched character also being followed by " -", which doesn't look so nice in the OSD message. This action looks for dash character that is at the end of the string, and replaces it with nothing.

My version:

1. Using Results.RegEx, I have the option of telling VC to search for a pattern in a string other than {LastResult}. Because of this, I'm able to directly look for and capture the pattern "\w" in {1}.

2. In the next action I concatenate together all the matches found, adding the delimiter " - " between the matches to create one string of the form: "\w - \w - \w". This concatenated string is now my {LastResult}.
(see http://voxcommando.com/mediawiki/index.php?title=Actions#MatchConcat)

---------------------
A cheat sheet to learn common regular expressions: http://www.mikesdotnetting.com/article/46/c-regular-expressions-cheat-sheet.

The RegEx tool in VoxCommando actually includes a link to that cheat sheet and a couple other online resources.
« Last Edit: November 25, 2014, 12:44:04 PM 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)

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: "how do you spell ...."
« Reply #5 on: November 26, 2014, 05:32:11 AM »
@ nime5ter: Thank you for the inspiration  ;)
I think you have a better idea for the RegEx  ::hmm

Here is a group which contains following commands: spelling a word, spelling the word again , noun for a word, synonyms for a word
Copy and paste the code in your VC command tree and have fun.

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.2.3-->
<commandGroup open="True" name="spelling a word" enabled="True" prefix="" priority="0" requiredProcess="" description="">
  <command id="359" name="How do you spell {1}" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>(\w)</param>
        <param />
        <param>{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.MatchConcat</cmdType>
      <params>
        <param> - </param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
        <param>7000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>{1} is spelt, {LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.SetVar</cmdType>
      <params>
        <param>spell</param>
        <param>{1} is spelt, {LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>How do you spell</phrase>
    <payloadDictation>payloadDictation: Regular</payloadDictation>
  </command>
  <command id="386" name="How do you spell {1} repeat" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{Var.spell}</param>
        <param>7000</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>TTS.Speak</cmdType>
      <params>
        <param>no problem, please listen again: {Var.spell}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <phrase>can you repeat it, please repeat, can you spell it again, I have not heard right</phrase>
  </command>
  <command id="369" name="noun of" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://www.thesaurus.com/browse/{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>class="ttl"&gt;(\w.*?)&lt;</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{#M}&amp;&amp;0</ifParams>
      <then>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>no match found</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>Sorry, no match found.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>{Match.1}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>the noun of {1} is, {Match.1}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <phrase>how is the noun of</phrase>
    <payloadDictation>payloadDictation: Regular</payloadDictation>
  </command>
  <command id="377" name="synonym" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
    <action>
      <cmdType>Scrape</cmdType>
      <params>
        <param>http://www.thesaurus.com/browse/{1}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.RegEx</cmdType>
      <params>
        <param>&lt;span.class="text"&gt;(.*?)&lt;</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>Results.MatchConcat</cmdType>
      <params>
        <param>, {CR}</param>
        <param>5</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <action>
      <cmdType>OSD.ShowText</cmdType>
      <params>
        <param>{LastResult}</param>
      </params>
      <cmdRepeat>1</cmdRepeat>
    </action>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)==(B)</ifType>
      <ifParams>{#M}&amp;&amp;0</ifParams>
      <then>
        <action>
          <cmdType>OSD.ShowText</cmdType>
          <params>
            <param>no match found.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>TTS.SpeakSync</cmdType>
          <params>
            <param>Sorry, no match found.</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
        <action>
          <cmdType>VC.StopMacro</cmdType>
          <params />
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else />
    </if>
    <if ifBlockDisabled="False" ifNot="False">
      <ifType>(A)&lt;(B)</ifType>
      <ifParams>{#M}&amp;&amp;2</ifParams>
      <then>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>here are a synonym for {1}: {LastResult}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </then>
      <else>
        <action>
          <cmdType>TTS.Speak</cmdType>
          <params>
            <param>here are some synonyms for {1}: {LastResult}</param>
          </params>
          <cmdRepeat>1</cmdRepeat>
        </action>
      </else>
    </if>
    <phrase>did you have synonyms for</phrase>
    <payloadDictation>payloadDictation: Regular</payloadDictation>
  </command>
</commandGroup>
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: "how do you spell ...."
« Reply #6 on: November 26, 2014, 08:28:53 AM »
Fun additions. You've taken PegLeg's request to a whole new level. :)

The synonym command works really well.

For me, it is hard to say the word "synonym" (it often comes out "cinnamon"), so I would probably change that command phrase (or add the phrase), "What's another word for ..."

I think that for the other definition command ("noun" = "das Substantiv", nicht "die Definition"), Thesaurus.com may not be the best choice. Sometimes it gives a definition, but sometimes it only gives associated words instead. Maybe we could find a better website for definitions?

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)

Kalle

  • $upporter
  • Hero Member
  • *****
  • Posts: 2320
  • Karma: 47
    • View Profile
Re: "how do you spell ...."
« Reply #7 on: November 26, 2014, 09:14:37 AM »
Yes, I'm complete with you. I used this website, because it was easy to ge a match with regex  :)
***********  get excited and make things  **********

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: "how do you spell ...."
« Reply #8 on: November 26, 2014, 09:56:21 AM »
Yes, the dictionary websites are messy. For definitions, it's probably more reliable to adapt one of our Wolfram Alpha or Wikipedia commands.
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)

PegLegTV

  • $upporter
  • Sr. Member
  • *****
  • Posts: 497
  • Karma: 43
    • View Profile
Re: "how do you spell ...."
« Reply #9 on: November 26, 2014, 06:14:40 PM »
now that's cool, just have to make sure my kids don't use it to cheat on there vocabulary home work >:D  once again you guys go above and beyond thanks again    :yay