this unit converter relies on Google, so it need internet connection. the advantage that it can convert from any unit to any unit... just add what you use to xml payload
check
https://support.google.com/websearch/answer/3284611?hl=en-CA#unitconverter for full list of supported units ...
here is a new command, that is memory & SP version friendly .... this version requires PY plug-in and attached PY script to be loaded at start-up ( based on
http://voxcommando.com/forum/index.php?topic=1769.msg15399#msg15399 which list james PY script)
range is limited between - 999999999.xxx to 999999999.xxx (can be increased !!!!)
I would build multiple commands based on conversion type, ie. one for weight, one for volume ...etc. to increase recognition accuracy (avoid converting 3 cubic meters to square centimeters)
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="226" name="Unit Converter" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="<H2 class=r style="FONT-SIZE: 138%; DISPLAY: inline">20 kilograms = 44.0924524 pounds</H2>">
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>Number</param>
<param><![CDATA[ ]]></param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetLastResult</cmdType>
<params />
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>(A)Contains(B)</ifType>
<ifParams>{LastSpoken}&&point</ifParams>
<then>
<action>
<cmdType>Results.RegEx</cmdType>
<params>
<param>(.*?)\spoint\s(.*?){PF.1}</param>
<param />
<param>{LastSpoken}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>PY.ExecString</cmdType>
<params>
<param>result = txt2int ("{Match.1.2}")</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>Number</param>
<param>.{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.SetLastResult</cmdType>
<params>
<param>{Match.1.1} {PF.1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>Results.SetLastResult</cmdType>
<params>
<param>{LastSpoken}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<action>
<cmdType>Results.Replace</cmdType>
<params>
<param>minus</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegEx</cmdType>
<params>
<param>Convert\s(.*?){PF.1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>PY.ExecString</cmdType>
<params>
<param>result = txt2int ("{Match.1}")</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>(A)Contains(B)</ifType>
<ifParams>{LastSpoken}&&minus</ifParams>
<then>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>Number</param>
<param>-{LastResult}{var.Number}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>Results.SetVar</cmdType>
<params>
<param>Number</param>
<param>{LastResult}{var.Number}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<action>
<cmdType>Results.SetLastResult</cmdType>
<params>
<param>{var.Number}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.ShowText</cmdType>
<params>
<param>{LastSpoken}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>OSD.AddText</cmdType>
<params>
<param>{LastResult}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Scrape</cmdType>
<params>
<param>https://www.google.ca/search?biw=1920&bih=939&noj=1&site=webhp&q=convert+{LastResult}+{1}+to+{2}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Results.RegExSingle</cmdType>
<params>
<param><h2\sclass="r".*?>(.*?)</h2></param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>LastActionSuccess</ifType>
<ifParams>&&</ifParams>
<then>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>{Match.1.1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>I think that can not be done !</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<phrase>Convert</phrase>
<phrase optional="true">minus</phrase>
<phrase optional="true">one, two, three, four, five, six, seven, eight, nine</phrase>
<phrase optional="true">hundred</phrase>
<phrase optional="true">and</phrase>
<phrase optional="true">twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety</phrase>
<phrase optional="true">one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen</phrase>
<phrase optional="true">million</phrase>
<phrase optional="true">and</phrase>
<phrase optional="true">one, two, three, four, five, six, seven, eight, nine</phrase>
<phrase optional="true">hundred</phrase>
<phrase optional="true">and</phrase>
<phrase optional="true">twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety</phrase>
<phrase optional="true">one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen</phrase>
<phrase optional="true">thousand</phrase>
<phrase optional="true">and</phrase>
<phrase optional="true">one, two, three, four, five, six, seven, eight, nine</phrase>
<phrase optional="true">hundred</phrase>
<phrase optional="true">and</phrase>
<phrase optional="true">twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety</phrase>
<phrase optional="true">zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen</phrase>
<phrase optional="true">point</phrase>
<phrase optional="true">one, two, three, four, five, six, seven, eight, nine</phrase>
<phrase optional="true">hundred</phrase>
<phrase optional="true">and</phrase>
<phrase optional="true">twenty, thirty, forty, fifty, sixty, seventy, eighty, ninety</phrase>
<phrase optional="true">zero, one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen</phrase>
<payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\MeasurementsUnits.xml</payloadFromXML>
<phrase>to</phrase>
<payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\MeasurementsUnits.xml</payloadFromXML>
</command>
old command ...
- be careful, do not put all units in one xml, as the matrix will be too big and VC will eat-up too much memory for nothing. instead create multiple commands and attach different xml. ex. one command for area, other for volume, third for currency ...etc. and keep it to minimum
- limited to the 2 ranges ... keep the ranges small (saves memory)
- won't work with SP
[/li]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.4.2-->
<command id="191" name="Convert" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="<H2 class=r style="FONT-SIZE: 138%; DISPLAY: inline">20 kilograms = 44.0924524 pounds</H2>
">
<if ifBlockDisabled="False" ifNot="False">
<ifType>(A)==(B)</ifType>
<ifParams>{#P}&&4</ifParams>
<then>
<action>
<cmdType>Results.SetLastResult</cmdType>
<params>
<param>{1}.{2}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Scrape</cmdType>
<params>
<param>https://www.google.ca/search?biw=1920&bih=939&noj=1&site=webhp&q=convert+{LastResult}+{3}+to+{4}&oq=convert+20+kg+to+lbs</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>Results.SetLastResult</cmdType>
<params>
<param>{1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<action>
<cmdType>Scrape</cmdType>
<params>
<param>https://www.google.ca/search?biw=1920&bih=939&noj=1&site=webhp&q=convert+{LastResult}+{2}+to+{3}&oq=convert+20+kg+to+lbs</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<action>
<cmdType>Results.RegExSingle</cmdType>
<params>
<param><h2\sclass="r".*?>(.*?)</h2></param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
<if ifBlockDisabled="False" ifNot="False">
<ifType>LastActionSuccess</ifType>
<ifParams>&&</ifParams>
<then>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>{Match.1.1}</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</then>
<else>
<action>
<cmdType>TTS.Speak</cmdType>
<params>
<param>I think that can not be done !</param>
</params>
<cmdRepeat>1</cmdRepeat>
</action>
</else>
</if>
<phrase>Convert</phrase>
<payloadRange>1,10000</payloadRange>
<phrase optional="true">point</phrase>
<payloadRange optional="true">1,999</payloadRange>
<payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\MeasurementsUnits.xml</payloadFromXML>
<phrase>to</phrase>
<payloadFromXML phraseOnly="False" use2partPhrase="False" phraseConnector="by" Phrase2wildcard="anyone" optional="False">payloads\MeasurementsUnits.xml</payloadFromXML>
</command>