Skip to main content
September 23, 2014
Mobile

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