September 23, 2014 12:53 pm

Cortana Integration and Speech Recognition: New Code Samples

The blog post was authored by Steve White, Senior Content Developer, Content Publication Team

One of the strengths of Cortana is its ability to understand and respond to voice commands. The Windows Runtime API enables you to integrate your app with Cortana and make use of Cortana’s voice commands, speech recognition, and speech synthesis (text-to-speech, or TTS).

It is also possible to voice-enable your apps by implementing speech recognition and TTS capabilities.

We have just published a set of new sample apps that show you how to do these integrations. These two samples are for Windows Phone 8.1, and they complement the existing samples for Windows Phone Silverlight.

Let’s take a look at them…

Voice Commands Quickstart

This sample app illustrates the use of voice commands with Cortana. The sample app and code are provided in both XAML/C# and HTML/JavaScript. In each case, you’ll learn how to do the following:

  • Author and configure your Voice Command Definition (VCD) file.
  • Handle your app being activated by a voice command.
  • Determine whether the command that activated your app was actually spoken, or whether it was typed in as text. This is important so your app can deliver an in-kind response.
  • Navigate to a page in your app based on parameters in a voice command.
  • Use phrase topics to allow dictation to be part of a voice command and to further refine the relevance of speech recognition results.
  • Use text-to-speech (TTS) to give audible feedback about the voice command.
  • Programmatically redefine a phrase list.

Speech Recognition and TTS Quickstart

This sample illustrates the use of speech recognition and text-to-speech (TTS) facilities within your app. This sample is presented in XAML/C#. You’ll learn how to do the following:

  • Enable users to freely dictate a short message and speak web search keywords.
  • Create a list constraint so that the words or phrases to listen for are defined by a list you supply.
  • Use a SRGS grammar file constraint so that the words or phrases to listen for are defined by a grammar you supply.
  • Recognize continuously using a SRGS grammar file constraint. Your user can speak phrases from the grammar continuously and then end the recognition session with a particular word or phrase.
  • Choose an installed voice, and have it read back some text that your user enters into a text input box.

These tools offer a great way to bring more users into your app and to give them a richer, more powerful, and more natural experience. Try it out.

More Cortana and speech recognition resources

MSDN “How to” article on speech interactions in XAML apps: Responding to speech interactions (XAML)

MSDN “How to” article on speech interactions in HTML apps: Responding to speech interactions (HTML)

A One Dev Minute video on Channel 9: Integrating Cortana with your App

Session slides and video from the Cortana/speech session at //build/2014: Integrating Your App into the Windows Phone Speech Experience


Updated November 7, 2014 11:25 pm

Join the conversation

  1. How is this different from Windows 7 Microsoft System.Speech v4.0 ?? I am trying to find out how to integrate my visual studio app with the built in speech engine that windows uses, including windows 8.1 (or 7). In this new style it appears you just change your “Grammars” and provide a list of what you want it to understand.

    But, on my Windows 7 machine, it has a speech to text built in application, i can use it to launch programs or dictate, and it has a training method to read about 100 sentences for 30 minutes and that helps it understand how to recognize the persons speech. But I am struggling to find out how to build this app because it seems ALL support for the old style has dried up, and its all about using the new style with the custom grammars. Just after i got my app working good in windows 7. We only use win7 and 8.1 absolutely no chance of using Win 10 this year.

    How can I find out that, if I make an app with visual studio 2015, Microsoft System.Speech v4.0 will it try to use the built in speech engine that windows 7 or 8.1 has already? the hope is that if so, each user can train their PC for their voice and my app runs better.

    It seems the only support out there is for this new style and you define grammars. can this be loaded onto win7 or win8.1 ??