Is it possible to use simple voice commands like "run right", "run left", "jump", "stop", "attack", "defend", "finish" to control the player in a Windows Phone 8 game?

How can I implement voice recognition and some voice commands in my game?

  • 1
    \$\begingroup\$ Cons: reflex speed, people have to talk to their phone in public, it's awkward in general, speech recognition failure. \$\endgroup\$ May 30, 2014 at 14:37
  • \$\begingroup\$ Please don't make this the only way to play. \$\endgroup\$ May 30, 2014 at 14:39
  • 1
    \$\begingroup\$ The "pros and cons" of doing this is a list-generation question, and your question about difficulty is opinion-based (both considered a poor fit for this site). I've edited them out of your question so as to focus on the main interesting query. \$\endgroup\$
    – user1430
    May 30, 2014 at 15:21

2 Answers 2


Yes, you can use voice commands in Windows Phone 8 applications. It's relatively straightforward, you need to create an XML file that maps spoken commands to actions (a VCD file) and then add the code to initialize the speech subsystem with your definitions file and handle the triggered actions. The definition file contains XML like:

<Command Name="RunDirection">
  <Example>Run right</Example>
  <ListenFor>Run {direction}</ListenFor>
  <Feedback>Running {direction}!</Feedback>
  <Navigate Target="/run.xaml"/>

(Full reference for the XML schema is available here.)

You then call InstallCommandSetsFromFileAsync to register the commands file, and you accept commands via the OnNavigatedTo hander:

if (NavigationContext.QueryString.ContainsKey("voiceCommandName")) {
  var command = NavigationContext.QueryString["voiceCommandName"];
  if (command == "RunDirection") {
    var direction = NavigationContext.QueryString["direction"];

    m_player.SetDirection(direction); // ...or whatever.

Far more complete overviews are available at the MSDN and via this MSDN magazine article.

Note that the system is not well suited to real-time iterative direction like you are suggesting; you invoke the voice commands by hitting the Start button, and saying something like ", run right" (although the prefix is optional).

Further, if the system fails to understand you it may come up with a disambiguation prompt, which will interrupt the action (this may be optional too, I haven't explored it deeply enough).

It's probably not a very good mechanism to control the actual gameplay, although you may be able to use it for things like showing high scores, starting a new game, and so on.

  • \$\begingroup\$ Is it not possible to use the voice commands without hitting the Start button every time? I don't want to interrupt the game if I want to speak to my character. \$\endgroup\$ May 30, 2014 at 17:09
  • \$\begingroup\$ As far as I know, no. But I don't know that much about it (I've only dabbled with them), so it's possible somebody more knowledgeable will know of a way to get around that. If you use a third-party API (I know of none), you may also be able to avoid it. \$\endgroup\$
    – user1430
    May 30, 2014 at 17:14

Yes, it's possible. First find a suitable voice recognition library or use the "built in" option. Then map commands from the voice recognition library to input commands in your game.

As for design implementation, you can look at an existing game, There came an echo. Implementing commands like "run right" or "jump" are likely going to be too challenging to use, since those types of commands are highly dependent on timing.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .