Author Topic: Alternatives to using a lot of if() cases?  (Read 2070 times)

0 Members and 1 Guest are viewing this topic.

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Alternatives to using a lot of if() cases?
« on: July 18, 2015, 01:03:35 PM »
Okey thanks.... And off-top can {LastSpoken} use many param or values , for example for speech it (|) , for phrase it (,)?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Alternatives to using a lot of if() cases?
« Reply #1 on: July 18, 2015, 01:16:24 PM »
{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

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Alternatives to using a lot of if() cases?
« Reply #2 on: July 18, 2015, 01:23:54 PM »
For don`t do many if() i want insert in Last spoken different phrases... It`s it possibly?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Alternatives to using a lot of if() cases?
« Reply #3 on: July 18, 2015, 02:11:44 PM »
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

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Alternatives to using a lot of if() cases?
« Reply #4 on: July 18, 2015, 02:38:21 PM »
Code: [Select]
<?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

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Alternatives to using a lot of if() cases?
« Reply #5 on: July 18, 2015, 03:31:40 PM »
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:

Code: [Select]
<?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
« Last Edit: July 18, 2015, 04:52:34 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)

Slalomen

  • Jr. Member
  • **
  • Posts: 35
  • Karma: 0
    • View Profile
Re: Alternatives to using a lot of if() cases?
« Reply #6 on: July 18, 2015, 03:40:54 PM »
Thanks very much!!!!! 8)