locked
Best way to separate multiple commands? RRS feed

  • Question

  • Hi there. Bit of a newbie question I fear but here goes.

    What's the best way to keep commands for certain parts of the application separate from others? For example if I had "Start game" or "Exit" on the start screen, but didn't want those to be picked up within the game itself.

    Any suggestions welcome, even seemingly obvious ones.

    Friday, February 3, 2012 1:13 AM

Answers

  • Stupler,

    I think Emile solution isn't best for you. The only way to activate and deactivate commands in a grammar is to reload the grammar. This takes time, and isn't something I'd recommend. Instead, your application can listen to all commands at all times, but only act on commands at certain times. In your example, you can program it so that if a user says "start" or "exit" while on the start screen it processes the command, but if the start screen isn't visible it ignores the command. 

    -Chris

    • Proposed as answer by ChrisCicc Friday, February 3, 2012 6:59 PM
    • Marked as answer by Stupler Sunday, February 5, 2012 12:58 PM
    Friday, February 3, 2012 6:59 PM

All replies

  • If you define a grammar XML document, you can specify optional things for people to say (using item repeat="0-1"). Then, the string that is returned from the speech recognizer can be parsed by your program to further make sense of what the user is trying to do. Basically, a bunch of if statements (in its simplest form) would do the trick.
    Clever, witty forum signature.
    Friday, February 3, 2012 1:20 AM
  • Stupler,

    I think Emile solution isn't best for you. The only way to activate and deactivate commands in a grammar is to reload the grammar. This takes time, and isn't something I'd recommend. Instead, your application can listen to all commands at all times, but only act on commands at certain times. In your example, you can program it so that if a user says "start" or "exit" while on the start screen it processes the command, but if the start screen isn't visible it ignores the command. 

    -Chris

    • Proposed as answer by ChrisCicc Friday, February 3, 2012 6:59 PM
    • Marked as answer by Stupler Sunday, February 5, 2012 12:58 PM
    Friday, February 3, 2012 6:59 PM