Configuring Speech Recognizer Settings

Introduction

In this article we will learn about the settings for the recognizer in the Windows Phone 8 Speech Recognizer API.  You can customize the various settings to make the recognizer more effective. Recognizer is a part of speech recognition that controls the actions to be taken in the absence of input or unrecognizable speech. This component controls the speech recognition behavior when there is no input and in giving the conclusion of the speech recognition process.

Recognizer supports the following settings:

  1. Babble Timeout
     
  2. Initial Silence Time
     
  3. End Silence Time

The article contains the following topics:

  1. Speech Recognizer Settings
  2. Customizing The Settings

Speech Recognizer Settings

The following settings can be configured in the Speech Recognizer:

  1. Babble Timeout

    It's a time period during which the speech recognition discards the background noise or continues listening even if the input is background noise. Background noise consists of all the input that doesn't match any grammar rules defined in the speech recognition grammar. Once the babble time period is expired the Speech Recognizer concludes the recognition result. The default duration is 0 (the feature is disabled by default).

    Syntax:

    mic.Recognizer.Settings.BabbleTimeout = "time in seconds";
     
  2. Initial Silence Time

    It's a time period for which the recognizer must wait initially for speech input if the only input is silence. If the recognizer doesn't recognize the input within this time period then it will conclude the speech recognition result.
    This setting can be used to set the time for the user to get ready for input. The default value is 5 seconds.

    Synatx:

    mic.Recognizer.Settings.InitialSilenceTimeout = 0;
     
  3. End Silence Time

    It is a time period for which the Speech Recognizer must wait before finalizing the result of speech recognition, after speech has finished and only silence is being received as input. The default value for this setting is 150 milliseconds.

    Syntax:

    mic.Recognizer.Settings.EndSilenceTimeout = 0;
     

Customizing the Settings

The following code sample shows the usage of all settings described above:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Navigation;

using Microsoft.Phone.Controls;

using Microsoft.Phone.Shell;

using Demo.Resources;

using System.Threading;

using Windows.Phone.Speech.Recognition;

 

namespace Demo

{

    public partial class MainPage : PhoneApplicationPage

    {

        // Constructor

        public MainPage()

        {

            InitializeComponent();

        }

 

        private async void strtClick(object sender, RoutedEventArgs e)

        {

            List<string> sampleGrammar1 = new List<string>();

            sampleGrammar1.Add("Phone");

            sampleGrammar1.Add("Games");

            sampleGrammar1.Add("Music");

            sampleGrammar1.Add("Fun");

 

            SpeechRecognizerUI mic = new SpeechRecognizerUI();

            mic.Recognizer.Grammars.AddGrammarFromList("Grammar1", sampleGrammar1);

 

            //Timeout Settings

            mic.Recognizer.Settings.InitialSilenceTimeout = TimeSpan.FromSeconds(6);

            mic.Recognizer.Settings.EndSilenceTimeout = TimeSpan.FromSeconds(5);

            mic.Recognizer.Settings.BabbleTimeout = TimeSpan.FromSeconds(1);

 

            //start recognition process

            SpeechRecognitionUIResult res = await mic.RecognizeWithUIAsync();

            if (res != null)

            {

                MessageBox.Show("Text Input: " + res.RecognitionResult.Text + "\nGrammer Used: " + res.RecognitionResult.RuleName);

            }

        }

    }

}

 
 
Summary

That's all for this article. Just a small note that all the preceding settings work only for specific speech recognition instances. These settings don't effect the default device behavior and the settings are effective only if the grammar is defined explicitly.


Similar Articles