Author Topic: Parameterized Spoken Command  (Read 1452 times)

RuBa1987

  • Newbie
  • *
  • Posts: 4
Parameterized Spoken Command
« on: February 08, 2020, 05:13:31 AM »
I'm working on a plug-in and I'm having a little trouble getting this to work. I'm trying to get my plug-in setup similar to how HCS did it. When I look at their profile they have things like {TXT:SomeCommand} in the "Spoken Command" field in the profile. I have tried this and I can't get it to work like that in my profile.

I have vaProxy.SetText("TestCommand", "Testing"); in my init function and {TXT:TestCommand} in the "Spoken Command" field. When I say "Testing" it tells me the command is not recognized.

Any advice on this?

TheThingIs

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 278
    • HCS Voicepacks
Re: Parameterized Spoken Command
« Reply #1 on: February 08, 2020, 10:54:11 AM »
after setting the tokens you need to restart the profile so that the voice engine is reinitialised with the changed triggers
The Singularity profile - One profile to rule them all and at HCS we bound them ;)

You see, TheThingIs, eventually you'll be allright.

RuBa1987

  • Newbie
  • *
  • Posts: 4
Re: Parameterized Spoken Command
« Reply #2 on: February 09, 2020, 06:44:26 AM »
So I gave that a go and it's still not working for me. I even rebooted my computer, rebuilt the plugin, then launched VA and it's still not working. I have attached a screenshot of my code, VA not recognizing the command, the profile, and the command config.

I'm guessing I'm not checking a box or setting the right thing or something silly, I just can't figure out what it is.

TheThingIs

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 278
    • HCS Voicepacks
Re: Parameterized Spoken Command
« Reply #3 on: February 09, 2020, 10:45:00 AM »
set the token and then use the reinitialise profile cmd
The Singularity profile - One profile to rule them all and at HCS we bound them ;)

You see, TheThingIs, eventually you'll be allright.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Parameterized Spoken Command
« Reply #4 on: February 09, 2020, 10:53:18 AM »
You need to reload the profile, either by switching to another profile and back manually, or using the "Reset the Active Profile" action (either will also stop all running commands, and reset all variables that are not within a semi-persistent scope, I.E. all but global and ">>" prefixed variables).
The profile needs to be reloaded each time you make changes to the variables rendered by the tokens, if you want those changes to be reflected in the phrases you need to speak to trigger the commands that use them.

Variables are never persistent between VoiceAttack sessions, so you need to reload the profile at least once after your profile or plugin has set the values initially.

Note that the "Utility.ResetSpeechEngine()" method does not reload the profile to rebuild the phrase list, only the speech recognition engine itself (I.E. it will not apply changes to any command phrases).

Also note that variables/tokens in command phrases is an advanced and experimental feature.

RuBa1987

  • Newbie
  • *
  • Posts: 4
Re: Parameterized Spoken Command
« Reply #5 on: February 09, 2020, 03:51:44 PM »
I will give that a go but it seems a little odd to have to manually toggle that. I'm not sure how HCS did it but I have never had to do it with their setup.

Thanks for the heads up on it being experimental though, I didn't know that. I just saw they were doing it and figured it was a reasonable standard to follow instead of weird string matching in my code to detect the right thing. Is there any documentation on the feature yet? If you don't do it like that how do you build command libraries? Maybe I'm doing it wrong.

My thought was to have 1 plugin that would do a few dozen commands, didn't seem to make sense to write a few dozen plugins and doing things like if(vaProxy.Context == "Something") is just bad code when you end up with a bunch (or even a switch). I was trying to setup something a little more dynamic and cleaner than that if possible. At least hook it to variables or something and maybe use a little dynamic dispatch.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Parameterized Spoken Command
« Reply #6 on: February 09, 2020, 04:05:43 PM »
It is not documented in VoiceAttackHelp.pdf, however the original implementation was discussed here.


If HCS Voice Packs is using this feature, they are also reloading the profile. That is the only way to update the command phrases when the output of the tokens changes (E.G. because a variable value has changed).

I don't know what you're referring to with "command libraries". Or why having a switch statement would be "bad code".

If you want to pass parameters to a plugin from a command or vice-versa, you can use variables for that. The plugin context can be used to pass the variable name(s), if that needs to be dynamic as well (the fields other than "Plugin Context" are not used by the V4 plugin interface).

TheThingIs

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 278
    • HCS Voicepacks
Re: Parameterized Spoken Command
« Reply #7 on: February 09, 2020, 05:41:11 PM »
we do reset the profile, you just don't notice it :)
The Singularity profile - One profile to rule them all and at HCS we bound them ;)

You see, TheThingIs, eventually you'll be allright.

Malic

  • Full Member
  • ***
  • Posts: 105
Re: Parameterized Spoken Command
« Reply #8 on: February 14, 2020, 12:33:43 PM »
I do the same thing with my commands.

Sets all the variables for the commands on startup, and then have a reset profile command that can be found under:

Other > Voice Attack Action > Reset Active Profile

That lets the variables reload.

I just have mine play a chirp sound effect when everything is done loading so I know the profile is ready to go.

RuBa1987

  • Newbie
  • *
  • Posts: 4
Re: Parameterized Spoken Command
« Reply #9 on: February 14, 2020, 01:26:03 PM »
Yeah, I eventually got it working like that. I'm trying to find something a little more elegant that will work too. I also got it working with loading in a dummy profile but that's still not ideal. I tried to figure out how HCS did it but I think I might be on to another way. I might be able to access the memory space depending on how they load the dll in. If I write the plugin wrapper in C# but have that load in a C++ library I should be able to access a bit more and potentially handle it there. Hell, at that point I could just go modify the interned strings to be what I want but there is so much risk in something like that.

My problem is, this is the first time I'm working with this framework and I know very little about how it works which makes it a little tough to write something robust and distributable the way I want it to work. I could decompile the sources but I feel like that is basically cheating.

Malic

  • Full Member
  • ***
  • Posts: 105
Re: Parameterized Spoken Command
« Reply #10 on: February 15, 2020, 11:51:09 AM »
I have a startup command run when the profile is launched

In this, at the very end, I have it check a variable.  As the variable is not saved to profile, it does not exist, and thus, not set

If it sees that the variable is not set, I have it set the variable to TRUE, and then reset the profile.

When the profile is reset, as VA has not closed, now the variable is set to TRUE, and when it redoes all the startup commands, it sees "TRUE", skips the reset and then finishes the startup command.  I have mine then play a chirp sound to let me know that the profile is loaded, but at that point all the other variables are now loaded into VA as well, including the token for the other commands.


In the startup command:

Quote
Begin Boolean Compare : [>>initOnce] Has Not Been Set
    Execute command, 'reset profile' (and wait until it completes)
End Condition

In the reset profile command:

Quote
Begin Condition : [>>initOnce] Equals False OR [{CMDACTION}] Does Not Equal 'Profile'
    Write [color] 'RESETTING NEW COMMAND' to log
    Set Boolean [>>initOnce] to True
    Reset the active profile
End Condition


TheThingIs

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 278
    • HCS Voicepacks
Re: Parameterized Spoken Command
« Reply #11 on: February 16, 2020, 06:42:41 AM »
decompiling or affecting the memory space of our code is not something we would take kindly to, especially if you distribute it.
The Singularity profile - One profile to rule them all and at HCS we bound them ;)

You see, TheThingIs, eventually you'll be allright.