Author Topic: Pass spoken values through to backend?  (Read 1631 times)

Tazling

  • Newbie
  • *
  • Posts: 10
Pass spoken values through to backend?
« on: January 30, 2021, 06:20:52 PM »
I've been staring at the (very well written!) manual for a while here and I think the answer to my question is No, from what I've read.  But maybe I've missed something, so thought I'd ask.

I would like to do a voice command of prefix-suffix type, except that the suffix is the next voice input, passed through.  Like "warp .45", where "warp" tells VA to send a tilde (get into console) and type "warp " -- then the next words after that should be sent through as characters, "point four five".  Then maybe an end indicator, like the word "endit"... which causes VA to send a newline/cr, then wait N ms, then exit console.

It looks like this is not an option -- and if it isn't, then I can set up several prefix-suffix pairs for most commonly used warp values (1.0, .75, .50 etc) and be content.  Just curious, finding out the limits of the tool...

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4762
  • RTFM
Re: Pass spoken values through to backend?
« Reply #1 on: January 30, 2021, 06:41:13 PM »
If the intent is to be able to speak any number, you'd have to rely on wildcards, which is less accurate than pre-defining the possible combinations.

Have a look at the "Dynamic command sections" subsection of the "1 - Command Input" subsection of the "Command Screen" section of VoiceAttackHelp.pdf to see how you can do that efficiently, without creating separate commands for all of them.

The "{CMDSEGMENT:}" token is also very useful in this context, though note that it cannot be used for prefix/suffix commands by default, as processing the segments is performance-intensive.
If you really want to, you can enable the "Allow command segment info for composite commands" on the "System / Advanced" tab of the VoiceAttack options window, but with dynamic command sections I haven't personally had a need to.

If you combine that token with the "Quick Input" action, you can have it type out those characters, too.

Tazling

  • Newbie
  • *
  • Posts: 10
Re: Pass spoken values through to backend?
« Reply #2 on: January 31, 2021, 02:24:56 PM »
Great answer, though bits of it went over my n00by head :-)

It occurred to me that I'm being a bit over-clever (not the first time).  Once my game engine has gone into dev con, there's nothing to stop me from speaking multiple words to VA and having it type them in.  There's no need really to have single-word commands for every possible dev con setting, or get crazy with wildcards, pattern matching, etc. 

If I tell VA what to do about integers from zero to 9, plus "point", and "space"... then I can have one command like "warp" that types ~(wait)warp(space), then I say clearly "zero point four five enter" (pause a moment) then "tilde" to escape from dev con.  Or "weather" can trigger "~(wait)g_weather(space)" and then I can say "zero space i enter", pause a moment, then "tilde".  So any command that takes an argument can be used with arbitrary values.  I only have to tell VA what to do with the digits (and specific letters) that are used in cmd args.

This is a bit more talking, but the 10 integer command defs work for any numeric dev con parameter setting.  And I don't set this kind of stuff all the time :-)  so the extra seconds chatting with VA are not a burden.

This is my first time playing with voice recognition and I'm a bit dazzled by all the possibilities.  It's like a match made in heaven with VR :-)  thanks for the fantastic tool, and for patient answers to the inevitable Stupid Questions from the beginner.


dervonnebenaan

  • Newbie
  • *
  • Posts: 3
Re: Pass spoken values through to backend?
« Reply #3 on: March 17, 2021, 01:04:02 AM »
Hey.

I hope this doesn't count as necro yet. I'm new and stumbled upon this thread. I think that you're trying to achieve the same thing that I just spent 3 hours on.  :)

The minimal case would be something like this:
When I say: "Write the number <x>."
-> VA writes "The user told me to write <x>. Have a nice day"

To achieve this, step by step:
  • Fill in the "When I say" field:   'Write the number [0..100]'  (in this case, VA will accept integers between 0 and 100. Adjust the range as needed)
  • Click "Other -> Advanced -> Set a Text Value"
  • Enter a variable name, e.g. 'ThatsWhatHeSaid'
  • In the "Set Text Value To:    •Text" field, type  '{CMD}'  (so now, we have stored the contents of your command in  a variable.)
  • Click "Other -> Advanced -> Set an Integer Value"
  • Enter another variable name, e.g. 'JustTheNumber'
  • Under "Set Integer Value To:" select "•Convert Text/Token" and type the following: '{TXTNUM:ThatsWhatHeSaid}'  (now we have extracted the number and stored it in the new variable)
  • Click "Other -> VoiceAttack Action -> Quick Input"
  • In the text field, type something like 'The user told me to write {INT:JustTheNumber}. Have a nice day.[ENTER]'
For a more complicated example with decimals and if-statements, see this post.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4762
  • RTFM
Re: Pass spoken values through to backend?
« Reply #4 on: March 17, 2021, 01:13:42 AM »
Unless you intend to use it later on, there is no reason to set a text variable.

As the documentation notes, the "{TXTNUM:}" token takes either variable name, or literal text. Tokens are literal text once they have been parsed, so you can pass the output of the "{CMD}" token directly to the "{TXTNUM:}" token.

In addition, again unless you actually intend to use it later, there is no reason to use an integer variable in your example (especially as you're only using text anyway, so you don't need an actual number, just the text that represents it), as the Quick Input action parses tokens.

The only required action in your example command would be the "Quick Input" action:
Code: [Select]
Quick Input, 'The user told me to write {TXTNUM:"{CMD}"}. Have a nice day.[ENTER]'

dervonnebenaan

  • Newbie
  • *
  • Posts: 3
Re: Pass spoken values through to backend?
« Reply #5 on: March 17, 2021, 01:22:28 AM »
I just realised it myself and came back to edit my post, but you were faster. ^^

Thx m8