Author Topic: Toggling - Stop/start listening with voice commands and other things  (Read 14435 times)

PotatoJedi

  • Newbie
  • *
  • Posts: 15
I recently downloaded the free trial version to see what Voice Attack is like and so far I'm extremely impressed. I've been using GlovePIE until now and while I'm relatively satisfied with it, there are some things which Voice Attack does better.

However, I'm struggling to figure out a way of toggling the stop/start listening mode using only voice commands. Basically, I'm trying to make it so that if I say a certain command (let's say "use microphone"), it will toggle between listening and not listening. Obviously, when it's not listening, it's not going to pick anything up. I found out that you can override that using the "Override listening if my command begins with" option in your profile, and while this does allow me to turn it back to listening, I need 2 separate commands to turn it on and off. I'd rather just have one that toggles between the two states. Is there any way that this can be done?

Also, how does the toggle feature work in general? I noticed that for regular keys there is an option to do that, but it doesn't appear to work the same way as if you want to hold the key down on your keyboard, i.e. it does hold it down, but the key isn't repeated over and over as if you were holding it down on the keyboard.

Also, how would you toggle mouse left/right clicks? There is no option to do so (only press and release) natively. Normally, in GlovePIE, I would simply create a variable.

Code: [Select]
If said("one",4) then toggle var.fire

If var.fire = true then Mouse.LeftButton = true else Mouse.LeftButton = false

But I have no idea how to do that in Voice Attack.

Thanks for any help! Really looking forward to further testing this program. Strongly considering purchasing the full product if I can get it to do what I need.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #1 on: January 10, 2017, 11:01:28 AM »
I need 2 separate commands to turn it on and off. I'd rather just have one that toggles between the two states. Is there any way that this can be done?
You can use the "{STATE_LISTENING}" token and respond accordingly:
Code: [Select]
Begin Text Compare : [{STATE_LISTENING}] Equals '1'
    Stop VoiceAttack listening
Else
    Start VoiceAttack listening
End Condition

Also, how does the toggle feature work in general? I noticed that for regular keys there is an option to do that, but it doesn't appear to work the same way as if you want to hold the key down on your keyboard, i.e. it does hold it down, but the key isn't repeated over and over as if you were holding it down on the keyboard.
Honestly I don't know why that is, in Windows(I think it's been that way since explicit DirectX input was no longer necessary, so it may have to do with that). However, in games it will hold down the key as you expect.

Also, how would you toggle mouse left/right clicks?
Same method, different token:
Code: [Select]
Begin Text Compare : [{STATE_LEFTMOUSEBUTTON}] Equals '0'
    Hold left mouse button down
Else
    Release left mouse button
End Condition
For the right mouse button, use the "{STATE_RIGHTMOUSEBUTTON}" token.
All tokens are listed in the VoiceAttackHelp.pdf file in your VoiceAttack installation directory. You can also open the file using the "VoiceAttack Documentation" shortcut in the "VoiceAttack" start menu folder.

PotatoJedi

  • Newbie
  • *
  • Posts: 15
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #2 on: January 10, 2017, 01:07:41 PM »
I need 2 separate commands to turn it on and off. I'd rather just have one that toggles between the two states. Is there any way that this can be done?
You can use the "{STATE_LISTENING}" token and respond accordingly:
Code: [Select]
Begin Text Compare : [{STATE_LISTENING}] Equals '1'
    Stop VoiceAttack listening
Else
    Start VoiceAttack listening
End Condition
Thanks for the reply. I did as you suggested. It works when toggling it off, but when I want to toggle it back on, it doesn't seem to register. It does work if I add in the "Override listening if my command begins with" option, but that requires an extra word as a prefix, which ideally I'd like to avoid. Is it possible to do it without? Am I just doing something incorrect? Here's a screenshot of what I've done:


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #3 on: January 10, 2017, 01:26:00 PM »
It does work if I add in the "Override listening if my command begins with" option, but that requires an extra word as a prefix, which ideally I'd like to avoid. Is it possible to do it without?
VoiceAttack will always run a command that has "Make VoiceAttack Start Listening" as the first action in the list when listening is disabled.

If you insist on having a single command, you can use a variable to toggle:
Code: [Select]
Start VoiceAttack listening
Begin Boolean Compare : [UseMicrophone] Equals False
    Set Boolean [UseMicrophone] to True
Else
    Stop VoiceAttack listening
    Set Boolean [UseMicrophone] to False
End Condition
The first time you run it listening will either toggle on or remain on, as it's not checking the actual listening state.

iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #4 on: January 10, 2017, 04:39:59 PM »
Once VA Stops listening, you'll have to use the Override command, otherwise, VA won't be listening.

I use the Override word Computer as my trigger. You could easily make a command called On;Off. Then you would just have to say, Computer On, or Computer Off, and the mic will turn On, Or Off.

It's a pretty natural trigger.

In your case, you could simply change your Override trigger word to USE, and change the command name to Microphone. That way, your still using Use Microphone as your trigger.

Or you could make a listening key to say the word to turn the mic back on. You could even make the listening key only work while in a certain program, like Elite Dangerous. Using this Token {ACTIVEWINDOWTITLE}.

It would then only turn on the mic while in Elite Dangerous, anywhere else, and it would do nothing.
« Last Edit: January 10, 2017, 04:52:32 PM by iceblast »

PotatoJedi

  • Newbie
  • *
  • Posts: 15
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #5 on: January 11, 2017, 10:58:21 AM »
It does work if I add in the "Override listening if my command begins with" option, but that requires an extra word as a prefix, which ideally I'd like to avoid. Is it possible to do it without?
VoiceAttack will always run a command that has "Make VoiceAttack Start Listening" as the first action in the list when listening is disabled.

If you insist on having a single command, you can use a variable to toggle:
Code: [Select]
Start VoiceAttack listening
Begin Boolean Compare : [UseMicrophone] Equals False
    Set Boolean [UseMicrophone] to True
Else
    Stop VoiceAttack listening
    Set Boolean [UseMicrophone] to False
End Condition
The first time you run it listening will either toggle on or remain on, as it's not checking the actual listening state.
Tried this as well. Still doesn't work without the Override command. Was I supposed to add anything else in the code other than what you wrote?

Once VA Stops listening, you'll have to use the Override command, otherwise, VA won't be listening.

I use the Override word Computer as my trigger. You could easily make a command called On;Off. Then you would just have to say, Computer On, or Computer Off, and the mic will turn On, Or Off.
Yeah, I could do that easily. It's just that I'm more used to toggling it on and off with one command as opposed to using 2 separate ones. It's not a huge deal or anything; I'm just stubborn that way. I'd rather stick with one, but if it's not possible, no big deal.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #6 on: January 11, 2017, 11:25:47 AM »
Was I supposed to add anything else in the code other than what you wrote?
Nope. As stated, if "Start VoiceAttack listening" is the first action in the list, the command will trigger even when listening is disabled.

PotatoJedi

  • Newbie
  • *
  • Posts: 15
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #7 on: January 11, 2017, 12:39:26 PM »
Was I supposed to add anything else in the code other than what you wrote?
Nope. As stated, if "Start VoiceAttack listening" is the first action in the list, the command will trigger even when listening is disabled.
Oh, man! Just tested it again and it's working perfectly. Thank you very much! Works just how I wanted it to.

iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #8 on: January 11, 2017, 03:14:26 PM »
I had tried your command yesterday, and it didn't work. You say today that it does work. So, I again tried the command and now it works. This seems to happen with you a great deal.  I didn't change the command at all, I just turned it back on, and it worked. It just sat there and played dumb for me yesterday. I even shut down VA and restarted, and nothing. Did you scold the command or something when I wasn't looking???

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #9 on: January 11, 2017, 03:51:59 PM »
I had tried your command yesterday, and it didn't work. You say today that it does work. So, I again tried the command and now it works.


I'll assume you shut your machine down for the night, in which case you've likely solved whatever was keeping it from working simply by restarting the system.

iceblast

  • Sr. Member
  • ****
  • Posts: 374
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #10 on: January 11, 2017, 04:39:53 PM »
I never turn off my computer, but every other command I had was working fine, just not that one. Usually, if a new command doesn't work, shutting down VA, and restarting it fixes the problem. It didn't have any effect on it. So, again, it had to be something you said that made it start working again. :) It's starting to become a trend here. You're using magic over there aren't you?! :)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #11 on: January 11, 2017, 05:02:17 PM »
You're using magic over there aren't you?! :)



EDIT: Fixed image links
« Last Edit: June 12, 2018, 04:46:06 PM by Pfeil »

PotatoJedi

  • Newbie
  • *
  • Posts: 15
Re: Toggling - Stop/start listening with voice commands and other things
« Reply #12 on: January 12, 2017, 06:30:58 AM »
Just thought I'd post a command I managed to figure out (after understanding how Pfeil's worked) that allows you to create a loop if you want it to repeatedly press a key when you say your command and then stop when you say it again. Nothing fancy, but considering I'm no programmer, I'm happy I managed to figure it out.  ::)

Code: [Select]
Begin Boolean Compare : [Something] Equals False
    Set Boolean [Something] to True
    Start Loop While : [Something] Equals True
        Press 1 key and hold for 0.05 seconds and release
    End Loop
Else
    Set Boolean [Something] to False
End Condition