News:

HOT TIP! Commands and groups can be copied and pasted directly from your command editor to the forum, and vice versa. This makes sharing command XML on the forum much easier!

Main Menu

Alternatives to using a lot of if() cases?

Started by Slalomen, July 18, 2015, 01:03:35 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Slalomen

Okey thanks.... And off-top can {LastSpoken} use many param or values , for example for speech it (|) , for phrase it (,)?

nime5ter

{LastSpoken} returns the last full phrase that VoxCommando recognized. It is based on what VoxCommando actually "heard" you saying.

What are you trying to do? There is probably a different solution.

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)

Slalomen

For don`t do many if() i want insert in Last spoken different phrases... It`s it possibly?

nime5ter

Can you post the xml for a command example?

It will be easier for me to make suggestions.

It is OK to post a Russian 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)

Slalomen

<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.5.1-->
<command id="148" name="Speed" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{LastSpoken}&amp;&amp;25</ifParams>
    <then>
      <action>
        <cmdType>DxInput.KeyPress</cmdType>
        <params>
          <param>7</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Sound.PlayWav</cmdType>
        <params>
          <param>E:\A.S.T.R.A VoicePack\A.S.T.R.A VoicePack wav\A.S.T.R.A VoicePack\engines thrusters and drives\etd increments\25 sir.wav</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)Contains(B)</ifType>
    <ifParams>{LastSpoken}&amp;&amp;пятьдесят</ifParams>
    <then>
      <action>
        <cmdType>DxInput.KeyPress</cmdType>
        <params>
          <param>8</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Sound.PlayWav</cmdType>
        <params>
          <param>E:\A.S.T.R.A VoicePack\A.S.T.R.A VoicePack wav\A.S.T.R.A VoicePack\engines thrusters and drives\etd increments\understood fifty percent.wav</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)Contains(B)</ifType>
    <ifParams>{LastSpoken}&amp;&amp;семьдесят пять</ifParams>
    <then>
      <action>
        <cmdType>DxInput.KeyPress</cmdType>
        <params>
          <param>9</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Sound.PlayWav</cmdType>
        <params>
          <param>E:\A.S.T.R.A VoicePack\A.S.T.R.A VoicePack wav\A.S.T.R.A VoicePack\engines thrusters and drives\etd increments\75%.wav</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)Contains(B)</ifType>
    <ifParams>{LastSpoken}&amp;&amp;максимум</ifParams>
    <then>
      <action>
        <cmdType>DxInput.KeyPress</cmdType>
        <params>
          <param>0</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>Sound.PlayWav</cmdType>
        <params>
          <param>E:\A.S.T.R.A VoicePack\A.S.T.R.A VoicePack wav\A.S.T.R.A VoicePack\engines thrusters and drives\etd increments\going to maximum.wav</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
      <action>
        <cmdType>VC.StopMacro</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else />
  </if>
  <phrase optional="true">Скорость</phrase>
  <phrase optional="true">на</phrase>
  <payloadList>25,пятьдесят,семьдесят пять,максимум</payloadList>
  <phrase optional="true">процентов</phrase>
  <phrase optional="true">скорости</phrase>
</command>

For example i want insert in Last spoken were value 25 more value for example "двадцать пять" because if more value VOX understand better

nime5ter

#5
Can you rename your wav files to make the names consistent?

e.g. "understood_пятьдесят.wav", "understood_25.wav", "understood_семьдесят пять.wav", "understood_максимум.wav"

?

Then you can use a Payload XML file, with your command like so:

<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.2.0.1-->
<command id="167" name="Speed" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>DxInput.KeyPress</cmdType>
    <params>
      <param>{1}</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>Sound.PlayWav</cmdType>
    <params>
      <param>E:\A.S.T.R.A VoicePack\A.S.T.R.A VoicePack wav\A.S.T.R.A VoicePack\engines thrusters and drives\etd increments\understood_{PF.1}.wav</param>
    </params>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <phrase optional="true">Скорость</phrase>
  <phrase optional="true">на</phrase>
  <payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\percent_velocity.xml</payloadFromXML>
  <phrase optional="true">процентов</phrase>
  <phrase optional="true">скорости</phrase>
</command>


See Payload XML file attached
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)

Slalomen