Author Topic: Looking for help with a typing command  (Read 3563 times)

filthymanc

  • Guest
Looking for help with a typing command
« on: July 28, 2018, 12:51:37 PM »
Hi,
I'm trying to figure out the best way to input a series of keystrokes on command.  It might sound easy but I want it to work in a specific way.

I'm playing DCS world in VR.
The plane I am flying has an ingame keyboard in the cockpit called the CDU.
The CDU allows me to type coordinates and other text in to the flight computer.
I have configured the game's control settings so that I can physically type on my realworld keyboard to make it easier than clicking the keys in the VR environment.


So for example, I have two ways at present to enter a coordinate.....
1) I can click on the ingame keyboard on the CDU using my mouse to point and click on the keys.
2) I can use my real keyboard on my lap to type out the text, which is directly input in to the CDU realtime.

Option 2 is by far the better, easier and practical than option 1.

Hope this make sense so far.

I'd now like a third option, the Voice Attack option.  This is causing me a bit of an issue because the easy way of doing this conflicts with other commands in my VA profile.

So here's what I want to do....

I want to type "NM469213" in to the CDU computer ingame.
Sounds easy?

I have already created 36 commands in VA which corresponds to every alphanumeric keystroke.
If I say "November Mike Four Six Nine Two One Three" VA could punch out every keystroke that corresponds, N M 4 6 9 2 1 3.
This is very simple and effective.

However, my VA profile uses the VAICOM PRO plugin. A complex in game communications plugin.  It allows me to speak to other ingame assets such as my wingmen for instance.  If I want to speak to my second or third wingman to give him a command I can simply say "Two, Close Up", "Three, Go Trail".  This clearly scuppers my plans for easy voice activated keyboard input as demonstrated above.  Every time I say the numbers one through to four, my profile thinks I'm speaking to my wingman and the plugin kicks in.

So I thought I'd try to use prefix and suffix.  I wanted to use a keyword indicating to VA that I am about to give a command that requires my 36 suffix commands all relating to each alphanumeric key.  I wanted to say prefix "Type" followed by suffix "November Mike Four Six Nine Two One Three".  But I failed immediately.  For this to work, I would have to actually say "Type November Type Mike Type Four Type Six Type Nine Type Two Type One Type Three" which is obviously not desirable.

I've had a search around for solutions but so far I haven't found anything.

I'd be really grateful to anyone who can offer up a solution to what seems to be a simple task, but is out of my current VA capabilities.

Thanks.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Looking for help with a typing command
« Reply #1 on: July 28, 2018, 02:40:11 PM »
You can block other commands by not checking the "Allow other commands to execute while this one is running" checkbox, provided you have the option to block cancelled commands enabled(rather than cuing them).

As for the input, rather than dealing with a heap of different commands that don't serve a purpose outside this context, I'd use the "Wait For Spoken Response" action instead:
Code: [Select]
Start Loop While : [1] Equals [1]
    Wait for spoken response: 'Alpha;Bravo;Charlie;Delta;Echo;Foxtrot;Golf;Hotel;India;Juliet;Kilo;Lima;Mike;November;Oscar;Papa;Quebec;Romeo;Sierra;Tango;Uniform;Victor;Whiskey;Xray;Yankee;Zulu;[1..9];N...'
    Begin Text Compare : [~response] Equals 'Cancel'
        Say, 'Input cancelled'
        Loop Break
    Else If Text Compare : [~response] Equals 'Enter'
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Press Enter key and hold for 0,06 seconds and release
        Loop Break
    Else If Text Compare : [~response] Equals 'Niner'
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Press 9 key and hold for 0,06 seconds and release
    Else
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Quick Input, '{TXTSUBSTR:~response:0:1}'
    End Condition
End Loop
The loop does a boolean compare of a variable named "1" against itself, with the "Evaluate 'Not Set' as false" option checked. This effectively makes it an infinite loop(You can check and set a variable instead, but I prefer loop break for convenience).

I added sounds when your commands are recognized(using a default Windows sound; You'd probably want to substitute your own, as the built-in ones are pretty quiet compared to a jet engine), if you want to use it without looking down at the CDU.

I'm using Quick Input more for my own convenience than anything else. You'll probably want to built out the conditional tree to use specific keypresses rather than straight letters for DCS, but it saves me writing them all out for testing.

filthymanc

  • Guest
Re: Looking for help with a typing command
« Reply #2 on: July 28, 2018, 03:08:06 PM »
You can block other commands by not checking the "Allow other commands to execute while this one is running" checkbox, provided you have the option to block cancelled commands enabled(rather than cuing them).

As for the input, rather than dealing with a heap of different commands that don't serve a purpose outside this context, I'd use the "Wait For Spoken Response" action instead:
Code: [Select]
Start Loop While : [1] Equals [1]
    Wait for spoken response: 'Alpha;Bravo;Charlie;Delta;Echo;Foxtrot;Golf;Hotel;India;Juliet;Kilo;Lima;Mike;November;Oscar;Papa;Quebec;Romeo;Sierra;Tango;Uniform;Victor;Whiskey;Xray;Yankee;Zulu;[1..9];N...'
    Begin Text Compare : [~response] Equals 'Cancel'
        Say, 'Input cancelled'
        Loop Break
    Else If Text Compare : [~response] Equals 'Enter'
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Press Enter key and hold for 0,06 seconds and release
        Loop Break
    Else If Text Compare : [~response] Equals 'Niner'
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Press 9 key and hold for 0,06 seconds and release
    Else
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Quick Input, '{TXTSUBSTR:~response:0:1}'
    End Condition
End Loop
The loop does a boolean compare of a variable named "1" against itself, with the "Evaluate 'Not Set' as false" option checked. This effectively makes it an infinite loop(You can check and set a variable instead, but I prefer loop break for convenience).

I added sounds when your commands are recognized(using a default Windows sound; You'd probably want to substitute your own, as the built-in ones are pretty quiet compared to a jet engine), if you want to use it without looking down at the CDU.

I'm using Quick Input more for my own convenience than anything else. You'll probably want to built out the conditional tree to use specific keypresses rather than straight letters for DCS, but it saves me writing them all out for testing.

Excellent, I shall study it and give it a good testing out.
Thanks.

filthymanc

  • Guest
Re: Looking for help with a typing command
« Reply #3 on: July 29, 2018, 08:57:00 AM »
You can block other commands by not checking the "Allow other commands to execute while this one is running" checkbox, provided you have the option to block cancelled commands enabled(rather than cuing them).

As for the input, rather than dealing with a heap of different commands that don't serve a purpose outside this context, I'd use the "Wait For Spoken Response" action instead:
Code: [Select]
Start Loop While : [1] Equals [1]
    Wait for spoken response: 'Alpha;Bravo;Charlie;Delta;Echo;Foxtrot;Golf;Hotel;India;Juliet;Kilo;Lima;Mike;November;Oscar;Papa;Quebec;Romeo;Sierra;Tango;Uniform;Victor;Whiskey;Xray;Yankee;Zulu;[1..9];N...'
    Begin Text Compare : [~response] Equals 'Cancel'
        Say, 'Input cancelled'
        Loop Break
    Else If Text Compare : [~response] Equals 'Enter'
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Press Enter key and hold for 0,06 seconds and release
        Loop Break
    Else If Text Compare : [~response] Equals 'Niner'
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Press 9 key and hold for 0,06 seconds and release
    Else
        Play sound, 'C:\Windows\media\Windows Navigation Start.wav'
        Quick Input, '{TXTSUBSTR:~response:0:1}'
    End Condition
End Loop
The loop does a boolean compare of a variable named "1" against itself, with the "Evaluate 'Not Set' as false" option checked. This effectively makes it an infinite loop(You can check and set a variable instead, but I prefer loop break for convenience).

I added sounds when your commands are recognized(using a default Windows sound; You'd probably want to substitute your own, as the built-in ones are pretty quiet compared to a jet engine), if you want to use it without looking down at the CDU.

I'm using Quick Input more for my own convenience than anything else. You'll probably want to built out the conditional tree to use specific keypresses rather than straight letters for DCS, but it saves me writing them all out for testing.

So this is what I came up with after studying your example. Please bear in mind this is my first attempt at this sort of command.  When I used your example I couldn't get it to work, so I wonder if I truly understood it. I'm still learning.

I'd be grateful for your observations on my attempt.

Code: [Select]
Start VoiceAttack listening
Play sound, 'C:\Windows\media\Windows Pop-up Blocked.wav'
Start Loop While :  Joystick 2 Button 3 Is Pressed
    Wait for spoken response: 'alpha;alfa;bravo;charlie;delta;echo;foxtrot;golf;hotel;india;juliet;kilo;lima;mike;november;oscar;papa;quebec;romeo;sierra;tango;uniform;victor;whiskey;whisky;xray;yankee;z...'
    Begin Text Compare : [a] Contains 'Alpha'
        Execute command, '((CDU A Key))'
    Else If Text Compare : [a] Contains 'Bravo'
        Execute command, '((CDU B Key))'
    Else If Text Compare : [a] Contains 'Charlie'
        Execute command, '((CDU C Key))'
    Else If Text Compare : [a] Contains 'Delta'
        Execute command, '((CDU D Key))'
    Else If Text Compare : [a] Contains 'Echo'
        Execute command, '((CDU E Key))'
    Else If Text Compare : [a] Contains 'Foxtrot'
        Execute command, '((CDU F Key))'
    Else If Text Compare : [a] Contains 'Golf'
        Execute command, '((CDU G Key))'
    Else If Text Compare : [a] Contains 'Hotel'
        Execute command, '((CDU H Key))'
    Else If Text Compare : [a] Contains 'India'
        Execute command, '((CDU I Key))'
    Else If Text Compare : [a] Contains 'Juliet'
        Execute command, '((CDU J Key))'
    Else If Text Compare : [a] Contains 'Kilo'
        Execute command, '((CDU K Key))'
    Else If Text Compare : [a] Contains 'Lima'
        Execute command, '((CDU L Key))'
    Else If Text Compare : [a] Contains 'Mike'
        Execute command, '((CDU M Key))'
    Else If Text Compare : [a] Contains 'November'
        Execute command, '((CDU N Key))'
    Else If Text Compare : [a] Contains 'Oscar'
        Execute command, '((CDU O Key))'
    Else If Text Compare : [a] Contains 'Papa'
        Execute command, '((CDU P Key))'
    Else If Text Compare : [a] Contains 'Quebec'
        Execute command, '((CDU Q Key))'
    Else If Text Compare : [a] Contains 'Romeo'
        Execute command, '((CDU R Key))'
    Else If Text Compare : [a] Contains 'Sierra'
        Execute command, '((CDU S Key))'
    Else If Text Compare : [a] Contains 'Tango'
        Execute command, '((CDU T Key))'
    Else If Text Compare : [a] Contains 'Uniform'
        Execute command, '((CDU U Key))'
    Else If Text Compare : [a] Contains 'Victor'
        Execute command, '((CDU V Key))'
    Else If : [a] Contains 'Whiskey' OR [a] Contains 'Whisky'
        Execute command, '((CDU W Key))'
    Else If Text Compare : [a] Contains 'Xray'
        Execute command, '((CDU X Key))'
    Else If Text Compare : [a] Contains 'Yankee'
        Execute command, '((CDU Y Key))'
    Else If Text Compare : [a] Contains 'Zulu'
        Execute command, '((CDU Z Key))'
    Else If Text Compare : [a] Contains 'Zero'
        Execute command, '((CDU 0 Key))'
    Else If Text Compare : [a] Contains 'One'
        Execute command, '((CDU 1 Key))'
    Else If Text Compare : [a] Contains 'Two'
        Execute command, '((CDU 2 Key))'
    Else If Text Compare : [a] Contains 'Three'
        Execute command, '((CDU 3 Key))'
    Else If : [a] Contains 'Four' OR [a] Contains 'for'
        Execute command, '((CDU 4 Key))'
    Else If Text Compare : [a] Contains 'Five'
        Execute command, '((CDU 5 Key))'
    Else If Text Compare : [a] Contains 'Six'
        Execute command, '((CDU 6 Key))'
    Else If Text Compare : [a] Contains 'Seven'
        Execute command, '((CDU 7 Key))'
    Else If Text Compare : [a] Contains 'Eight'
        Execute command, '((CDU 8 Key))'
    Else If Text Compare : [a] Contains 'Nine'
        Execute command, '((CDU 9 Key))'
    Else If Text Compare : [a] Contains 'Delete'
        Execute command, '((CDU CLR Key))'
    Else If Text Compare : [a] Contains 'Backspace'
        Execute command, '((CDU BCK Key))'
    End Condition
End Loop
Stop VoiceAttack listening
Play sound, 'C:\Windows\media\Windows Startup.wav'

Generally speaking it works.  I have a few problem with some of the words, such as 'echo', 'zero' and a few others.  I've tried to use Windows Speech Recognition to improve keywords, but that has had limited success. I also feel like it doesn't flow nicely, as if I have to put big pauses in between.

So I suppose I am now wondering if my command can be tidied up, improved, or made to be highly specific about what voice commands to listen to.  I feel like a bit of an idiot constantly repeating "echo, echo, echo".

Thanks

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Looking for help with a typing command
« Reply #4 on: July 29, 2018, 10:22:11 AM »
Generally speaking it works.  I have a few problem with some of the words, such as 'echo', 'zero' and a few others.  I've tried to use Windows Speech Recognition to improve keywords, but that has had limited success. I also feel like it doesn't flow nicely, as if I have to put big pauses in between.

So I suppose I am now wondering if my command can be tidied up, improved, or made to be highly specific about what voice commands to listen to.

Having to leave pauses in between phrases is necessary, you can't really eliminate that.

With responses you can't use more than 250 different phrases, so you can't use phrases like "alpha alpha" to allow for quicker input either.


As for things like "echo" getting recognized, that should improve with training, but may be limited by your microphone(if you're using the mic in your VR headset, make sure to train a profile with that; If you have a Vive, which has a relatively poor microphone, you may want to consider an external one) or your pronunciation.


I'd be grateful for your observations on my attempt.

It's worth remembering that an "Else If" tree is a process of elimination, I.E. once a certain comparison has been made it will not be made again.

Because of this, you can structure your tree differently to use only the starting character of your NATO alphabet words:
Code: [Select]
    Begin Text Compare : [a] Contains 'Zero'
        Execute command, '((CDU 0 Key))'
    Else If Text Compare : [a] Contains 'One'
        Execute command, '((CDU 1 Key))'
    Else If Text Compare : [a] Contains 'Two'
        Execute command, '((CDU 2 Key))'
    Else If Text Compare : [a] Contains 'Three'
        Execute command, '((CDU 3 Key))'
    Else If : [a] Contains 'Four' OR [a] Contains 'for'
        Execute command, '((CDU 4 Key))'
    Else If Text Compare : [a] Contains 'Five'
        Execute command, '((CDU 5 Key))'
    Else If Text Compare : [a] Contains 'Six'
        Execute command, '((CDU 6 Key))'
    Else If Text Compare : [a] Contains 'Seven'
        Execute command, '((CDU 7 Key))'
    Else If Text Compare : [a] Contains 'Eight'
        Execute command, '((CDU 8 Key))'
    Else If Text Compare : [a] Contains 'Nine'
        Execute command, '((CDU 9 Key))'
    Else If Text Compare : [a] Contains 'Delete'
        Execute command, '((CDU CLR Key))'
    Else If Text Compare : [a] Contains 'Backspace'
        Execute command, '((CDU BCK Key))'
    Else If Text Compare : [a] Starts With 'A'
        Execute command, '((CDU A Key))'
    Else If Text Compare : [a] Starts With 'B'
        Execute command, '((CDU B Key))'
    Else If Text Compare : [a] Starts With 'C'
        Execute command, '((CDU C Key))'
    Else If Text Compare : [a] Starts With 'D'
        Execute command, '((CDU D Key))'
    Else If Text Compare : [a] Starts With 'E'
        Execute command, '((CDU E Key))'
    Else If Text Compare : [a] Starts With 'F'
        Execute command, '((CDU F Key))'
    Else If Text Compare : [a] Starts With 'G'
        Execute command, '((CDU G Key))'
    Else If Text Compare : [a] Starts With 'H'
        Execute command, '((CDU H Key))'
    Else If Text Compare : [a] Starts With 'I'
        Execute command, '((CDU I Key))'
    Else If Text Compare : [a] Starts With 'J'
        Execute command, '((CDU J Key))'
    Else If Text Compare : [a] Starts With 'K'
        Execute command, '((CDU K Key))'
    Else If Text Compare : [a] Starts With 'L'
        Execute command, '((CDU L Key))'
    Else If Text Compare : [a] Starts With 'M'
        Execute command, '((CDU M Key))'
    Else If Text Compare : [a] Starts With 'N'
        Execute command, '((CDU N Key))'
    Else If Text Compare : [a] Starts With 'O'
        Execute command, '((CDU O Key))'
    Else If Text Compare : [a] Starts With 'P'
        Execute command, '((CDU P Key))'
    Else If Text Compare : [a] Starts With 'Q'
        Execute command, '((CDU Q Key))'
    Else If Text Compare : [a] Starts With 'R'
        Execute command, '((CDU R Key))'
    Else If Text Compare : [a] Starts With 'S'
        Execute command, '((CDU S Key))'
    Else If Text Compare : [a] Starts With 'T'
        Execute command, '((CDU T Key))'
    Else If Text Compare : [a] Starts With 'U'
        Execute command, '((CDU U Key))'
    Else If Text Compare : [a] Starts With 'V'
        Execute command, '((CDU V Key))'
    Else If Text Compare : [a] Starts With 'W'
        Execute command, '((CDU W Key))'
    Else If Text Compare : [a] Starts With 'X'
        Execute command, '((CDU X Key))'
    Else If Text Compare : [a] Starts With 'Y'
        Execute command, '((CDU Y Key))'
    Else If Text Compare : [a] Starts With 'Z'
        Execute command, '((CDU Z Key))'
    End Condition


Alternatively, you could combine this with my earlier example:
Code: [Select]
    Begin Text Compare : [a] Contains 'Zero'
        Execute command, '((CDU 0 Key))'
    Else If Text Compare : [a] Contains 'One'
        Execute command, '((CDU 1 Key))'
    Else If Text Compare : [a] Contains 'Two'
        Execute command, '((CDU 2 Key))'
    Else If Text Compare : [a] Contains 'Three'
        Execute command, '((CDU 3 Key))'
    Else If : [a] Contains 'Four' OR [a] Contains 'for'
        Execute command, '((CDU 4 Key))'
    Else If Text Compare : [a] Contains 'Five'
        Execute command, '((CDU 5 Key))'
    Else If Text Compare : [a] Contains 'Six'
        Execute command, '((CDU 6 Key))'
    Else If Text Compare : [a] Contains 'Seven'
        Execute command, '((CDU 7 Key))'
    Else If Text Compare : [a] Contains 'Eight'
        Execute command, '((CDU 8 Key))'
    Else If Text Compare : [a] Contains 'Nine'
        Execute command, '((CDU 9 Key))'
    Else If Text Compare : [a] Contains 'Delete'
        Execute command, '((CDU CLR Key))'
    Else If Text Compare : [a] Contains 'Backspace'
        Execute command, '((CDU BCK Key))'
    Else
        Execute command, '((CDU {TXTSUBSTR:a:0:1} Key))' (by name)
    End Condition

If you use actual numbers(either "0;1;2;3;4;5;6;7;8;9", or the shorthand "[0..9]"), you can reduce it further to
Code: [Select]
    Begin Text Compare : [a] Contains 'Delete'
        Execute command, '((CDU CLR Key))'
    Else If Text Compare : [a] Contains 'Backspace'
        Execute command, '((CDU BCK Key))'
    Else
        Execute command, '((CDU {TXTSUBSTR:a:0:1} Key))' (by name)
    End Condition



As a side note, you may notice the response variable I used was named "~response". The tilde("~") prefix signifies that this is a command-scoped variable, meaning it's discarded after the command stops.

Unless you plan to use the contents of a variable in more than one command, and they're not in the same execution chain, it's good practice to use a more limited scope.

One major benefit(though less relevant in this particular case), is that you can have multiple instances of the same command, or even multiple different commands, use the same variable name, and because it's scoped to that command or execution chain only, they won't interfere with each other.

See the "Advanced Variable Control (Scope)" chapter on page 173 of VoiceAttackHelp.pdf for more information.

filthymanc

  • Guest
Re: Looking for help with a typing command
« Reply #5 on: July 29, 2018, 10:47:16 AM »
Pfeil,
Thanks for taking the time out to explain this.  It is starting to make sense. I shall keep trying.
Thanks.
Filthymanc