UpdateRecognizerSetting Method (String, Int32)

Microsoft Speech Platform SDK 11

Collapse imageExpand ImageCopy imageCopyHover image

Updates the specified setting for the SpeechRecognitionEngine with the specified integer value.

Namespace:  Microsoft.Speech.Recognition
Assembly:  Microsoft.Speech (in Microsoft.Speech.dll)

Syntax

Visual Basic (Declaration)
Public Sub UpdateRecognizerSetting ( _
	settingName As String, _
	updatedValue As Integer _
)
Visual Basic (Usage)
Dim instance As SpeechRecognitionEngine
Dim settingName As String
Dim updatedValue As Integer

instance.UpdateRecognizerSetting(settingName, _
	updatedValue)
C#
public void UpdateRecognizerSetting(
	string settingName,
	int updatedValue
)

Parameters

settingName
Type: System..::..String

The name of the speech recognition engine setting.

updatedValue
Type: System..::..Int32

The updated value of the speech recognition engine setting.

Exceptions

ExceptionCondition
KeyNotFoundException

Thrown if the key specified by settingName could not be found.

Remarks

The only currently valid setting name is "BackgroundSpeechSensitivity". This setting can be used to adjust the speech recognition engine's sensitivity to speech that occurs in the background. Valid values for this setting are integers in the range -1 through 100, inclusive.

BackgroundSpeechSensitivity setting

Description

-1

It is unknown whether speech is expected.

0

Minimum sensitivity. This value is useful when no speech is expected in the background.

100

Maximum sensitivity. This value is useful when speech is expected in the background. This is the default value.

Examples

The following example is part of a console application that outputs the values for a number of the settings defined for the recognizer that supports the en-US locale. The example updates the confidence level settings, and then queries the recognizer to check the updated values. The example generates the following output.

 Copy imageCopy Code
Settings for recognizer MS-1033-80-DESK:

  ResourceUsage                  is not supported by this recognizer.
  HighConfidenceThreshold        = 80
  NormalConfidenceThreshold      = 50
  LowConfidenceThreshold         = 20
  ResponseSpeed                  = 150
  ComplexResponseSpeed           = 500
  AdaptationOn                   = 1
  PersistedBackgroundAdaptation  = 1

Updated settings:

  ResourceUsage                  is not supported by this recognizer.
  HighConfidenceThreshold        = 60
  NormalConfidenceThreshold      = 40
  LowConfidenceThreshold         = 15
  ResponseSpeed                  = 150
  ComplexResponseSpeed           = 500
  AdaptationOn                   = 1
  PersistedBackgroundAdaptation  = 1

Press any key to exit...
C# Copy imageCopy Code
using System;
using System.Globalization;
using Microsoft.Speech.Recognition;

namespace RecognizerSettings
{
  class Program
  {
    static readonly string[] settings = new string[] {
      "ResourceUsage",
      "HighConfidenceThreshold",
      "NormalConfidenceThreshold",
      "LowConfidenceThreshold",
      "ResponseSpeed",
      "ComplexResponseSpeed",
      "AdaptationOn",
      "PersistedBackgroundAdaptation"
    };

    static void Main(string[] args)
    {
      using (SpeechRecognitionEngine recognizer =
        new SpeechRecognitionEngine(new System.Globalization.CultureInfo("en-US")))
      {
        Console.WriteLine("Settings for recognizer {0}:",
          recognizer.RecognizerInfo.Name);
        Console.WriteLine();

        // List the current settings.
        ListSettings(recognizer);

        // Change some of the settings.
        recognizer.UpdateRecognizerSetting("HighConfidenceThreshold", 60);
        recognizer.UpdateRecognizerSetting("NormalConfidenceThreshold", 40);
        recognizer.UpdateRecognizerSetting("LowConfidenceThreshold", 15);

        Console.WriteLine("Updated settings:");
        Console.WriteLine();

        // List the updated settings.
        ListSettings(recognizer);
      }

      Console.WriteLine("Press any key to exit...");
      Console.ReadKey();
    }

    private static void ListSettings(SpeechRecognitionEngine recognizer)
    {
      foreach (string setting in settings)
      {
        try
        {
          object value = recognizer.QueryRecognizerSetting(setting);
          Console.WriteLine("  {0,-30} = {1}", setting, value);
        }
        catch
        {
          Console.WriteLine("  {0,-30} is not supported by this recognizer.",
            setting);
        }
      }
      Console.WriteLine();
    }
  }
}

See Also