1 out of 1 rated this helpful - Rate this topic

Handling issues with audio input for Windows Phone 8

April 14, 2014

Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1 only

The speech recognizer raises the SpeechRecognizerAudioProblemOccurred() event when it encounters conditions that interfere with accurate recognition of speech input. If you use the Windows.Phone.Speech.Recognition.SpeechRecognizerUI class, the event is also raised when speech recognition occurs on the Did you say screen.

You can use a handler for the event to retrieve a description of the audio problem, such as too quiet, too loud, too noisy, or too fast. You may be able to use the description of the audio problem to take steps improve the conditions for recognition, for example to prompt a user to speak louder.

The following example shows you how to register for the SpeechRecognizerAudioProblemOccurred() event and how to handle the event.

// Declare the SpeechRecognizerUI and SpeechSynthesizer objects at the class level.
SpeechRecognizerUI recoWithUI;
SpeechSynthesizer synth;

// Initialize the SpeechRecognizerUI and SpeechSynthesizer objects.
recoWithUI = new SpeechRecognizerUI();
synth = new SpeechSynthesizer();

// Register for the AudioProblemOccured event.
recoWithUI.Recognizer.AudioProblemOccurred += Recognizer_AudioProblemOccurred;

// Load the predefined dictation grammar and start recognition.
private async void Reco1_Click(object sender, RoutedEventArgs e)
{
  // Display text to prompt the user's input.
  recoWithUI.Settings.ListenText = "Trivia category?";

  // Give an example of ideal speech input.
  recoWithUI.Settings.ExampleText = " 'geography', 'movies', 'science' ";

  // Start recognition.
  SpeechRecognitionUIResult recoResult = await recoWithUI.RecognizeWithUIAsync();
}

// Handle the AudioProblemOccurred event.
async void Recognizer_AudioProblemOccurred(SpeechRecognizer sender, SpeechAudioProblemOccurredEventArgs args)
{

  // If input speech is too quiet, prompt the user to speak louder.
  if (args.Problem == SpeechRecognitionAudioProblem.TooQuiet)
  {
    await synth.SpeakTextAsync("Try speaking louder");
  }
}

There are many other speech recognition errors and exceptions that you may encounter when working with the feature. For more info, see Handling errors in speech apps for Windows Phone 8.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.