Author Topic: How do to conversion of units  (Read 1246 times)

noicevoice

  • Guest
How do to conversion of units
« on: December 02, 2018, 05:36:54 AM »
Sorry if this has been asked before and I couldn't find it. I tried searching for a few keywords but didn't come up with anything.

What I want to do is conversions of units, for example imperial to metric speed or the other way round.

What I tried to set up is
1) prefix "convert"

2) suffic command "test"
Play sound, '{VA_SOUNDS}\Speech Signal High.wav'
Start Dictation Mode (Clearing Dictation Buffer)
Pause 4 seconds
Stop Dictation Mode
Play sound, '{VA_SOUNDS}\Speech Signal High.wav'
Say, '{DICTATION}'

And that part works. What it does is when I say "convert test" it beeps, I can dictate, it waits 4 seconds then stops the dictation, beeps again and reads back what it caught.


Now I got three questions:
1) is there a better way to handle the dictation duration other than pausing 4 seconds?
E.g. if I say twenty (20) version twohundredsixtyninethousandfivehundredthirtyone (269531)

2) is there a way to dictate in single numbers and get the end result as one number?
E.g. if I say one two four two >> 1342

3) How do I go about converting the dication buffer to a different unit so that Say, '' can read out the converted result?
E.g. if I dictate a number in km/h and want to convert to knots,
1km/h is roughly 0,54 knots - is there a way how I can use a formula like:
{DICTATION}/*0,54


Sorry if all this has been asked and answered before.  :-[

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: How do to conversion of units
« Reply #1 on: December 02, 2018, 06:43:41 AM »
1) is there a better way to handle the dictation duration other than pausing 4 seconds?
E.g. if I say twenty (20) version twohundredsixtyninethousandfivehundredthirtyone (269531)

You can wait until something has been dictated:
Code: [Select]
Start Dictation Mode (Clearing Dictation Buffer)
Start Loop While : [{DICTATION}] Equals ''
End Loop
Stop Dictation Mode

You can also use that method to wait for a keypress:
Code: [Select]
Start Dictation Mode (Clearing Dictation Buffer)
Start Loop While :  Keyboard Key 'Enter' Is Not Pressed
End Loop
Stop Dictation Mode

2) is there a way to dictate in single numbers and get the end result as one number?
E.g. if I say one two four two >> 1342
You can speak up to six digits at a time and they'll be interpreted by the speech engine as a single number; Any more than that and it'll assume you're trying to dictate a phone number.

If you want to pause between each digit, you'll have to convert from text to numbers, as the speech engine will write them out(E.G. 1 will be recognized as "One").

Alternatively you can use the "Wait For Spoken Response" action, which will return numbers if specified(E.G. "[0..9]") to append a text value, though this option is only suitable for single digits or small numbers(it is restricted to a maximum of 250 different responses for performance reasons).


3) How do I go about converting the dication buffer to a different unit so that Say, '' can read out the converted result?
E.g. if I dictate a number in km/h and want to convert to knots,
1km/h is roughly 0,54 knots - is there a way how I can use a formula like:
{DICTATION}/*0,54
You can convert the dictation text to a numeric variable and use the "Computed value" option relevant to that variable, but what you're describing can be done using the "{EXP:}" and/or "{EXPDECINV:}" tokens(VoiceAttackHelp.pdf page 144 to 147).

E.G.
Code: [Select]
Say, '{EXPDECINV: {DICTATION} * 0.54}'

noicevoice

  • Guest
Re: How do to conversion of units
« Reply #2 on: December 02, 2018, 03:34:12 PM »
Thanks a lot! Had trouble setting up EXPDECINV first but that was due to me being on v1.7.2 - as soon as I updated to v1.7.3 it worked perfectly.

That documentation is really amazing by the way - if you know what to look for.

Will try and do some more research to fix my two remaining issues:
  • It converts to high resolution numbers, e.g. 10.x instead of "just" 10
  • "Repeat" doesn't work because of the way I set up "Start Dictation Mode (Clearing Dictation Buffer)" - since it repeats the whole command chain it clears the buffer and doesn't repeat the output

I will experiment with maybe clearing the buffer after a pauseĀ“of a few seconds.

Thanks a ton for the help! That has been invaluable. :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: How do to conversion of units
« Reply #3 on: December 03, 2018, 12:14:22 AM »
1. It converts to high resolution numbers, e.g. 10.x instead of "just" 10
The simplest way is to convert to integer:
Code: [Select]
Set integer [~converted] value to the converted value of {EXPDECINV: {DICTATION} * 0.54}
Say, '{INT:~converted}'

You can also convert to a decimal value, in which case you can use the "Round value to decimal places" option.


2. "Repeat" doesn't work because of the way I set up "Start Dictation Mode (Clearing Dictation Buffer)" - since it repeats the whole command chain it clears the buffer and doesn't repeat the output
Assuming "Repeat" is a "When I say" value, you can check whether that's been spoken and react accordingly:
Code: [Select]
Begin Text Compare : [{CMD}] Equals 'repeat'
    Say, '{EXPDECINV: {DICTATION} * 0.54}'
End Condition - Exit when condition met

If you're using prefix/suffix(in which case I'd recommend looking into "Dynamic command sections", as those can be much more flexible) you'll want to use "{PREFIX}" or "{SUFFIX}" instead of "{CMD}".