Partager via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

SpeechRecognitionEngine.QueryRecognizerSetting Method

Returns the values of the current settings for a speech recognition engine managed by a SpeechRecognitionEngine object.

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

Syntax

'Declaration
Public Function QueryRecognizerSetting ( _
    settingName As String _
) As Object
'Usage
Dim instance As SpeechRecognitionEngine
Dim settingName As String
Dim returnValue As Object

returnValue = instance.QueryRecognizerSetting(settingName)
public Object QueryRecognizerSetting(
    string settingName
)

Parameters

Return Value

Type: System.Object
The value of the setting.

Exceptions

Exception Condition
ArgumentNullException

settingName is a null reference (Nothing in Visual Basic).

ArgumentException

settingName is the empty string ("").

KeyNotFoundException

The recognizer does not have a setting by that name.

Remarks

Recognizer settings can contain string, 64-bit integer, or memory address data. The following table describes the settings that are defined for a recognizer that complies with the Microsoft Speech Platform SDK 11. The following settings must have the same range for each recognizer that supports the setting. A recognizer that complies with the Speech Platform SDK 11 is not required to support these settings and can support other settings.

Name

Description

ResourceUsage

Specifies the recognizer's CPU consumption. The range is from 0 to 100. The default value is 50.

CFGConfidenceRejectionThreshold

The speech recognition engine accepts full utterances with confidence scores above or equal to this threshold, and rejects full utterances with phrase confidence scores below this threshold. This property accepts the following values:

  • The value -1 causes the engine to use its default value.

  • A value in the range of 0-100 sets the phrase confidence rejection threshold to the specified value.

If this value is set to 0, the speech recognition accepts all utterances. If this value is set to 100, the speech recognition engine rejects all utterances.

ResponseSpeed

Indicates the length of silence at the end of unambiguous input before the speech recognizer completes a recognition operation. The range is from 0 to 10,000 milliseconds (ms). This setting corresponds to the recognizer's EndSilenceTimeout property. Default = 500ms.

ComplexResponseSpeed

Indicates the length of silence at the end of ambiguous input before the speech recognizer completes a recognition operation. The range is from 0 to 10,000 ms. This setting corresponds to the recognizer's EndSilenceTimeoutAmbiguous property. Default = 750ms.

EngineThreadPriority

Sets the priority of the engine thread(s). The range of permitted values is defined by the OS.

  • The minimum value is min(THREAD_PRIORITY_IDLE,THREAD_PRIORITY_HIGHEST)

  • The maximum value is max(THREAD_PRIORITY_IDLE,THREAD_PRIORITY_HIGHEST)

The values of these constants are in defined winbase.h.

AssumeCFGFromTrustedSource

Bypasses file integrity checks when loading a CFG, to reduce load time. This should *only* be used by applications that can guarantee that the CFG they are loading has previously been compiled by the application (or by another application it trusts) and has been stored in a secure location where it could not be edited by a malicious agent. This property accepts the following values:

  • Value set to 0 = AssumeCFGFromTrustedSource is OFF

  • Value set to 1 = AssumeCFGFromTrustedSource is ON

To dictate the confidence level at which higher values indicate recognized speech, and equal or lower values indicate rejected speech, use CFGConfidenceRejectionThreshold. Recognition results with confidence values greater than or equal to the CFGConfidenceRejectionThreshold trigger a SpeechRecognized event. Recognition results with confidence values less than the CFGConfidenceRejectionThreshold trigger a SpeechRecognitionRejected event.

The confidence scores assigned to words and phrases by the recognition engine become the values of the RecognizedWordUnit.Confidence and RecognizedPhrase.Confidence properties, and are converted to range from 0 to 1, instead of from 0-100.

To modify one of the recognizer's settings, use one of the UpdateRecognizerSetting methods.

You can modify how the speech recognition responds to non-speech input using the BabbleTimeout, InitialSilenceTimeout, EndSilenceTimeout, and EndSilenceTimeoutAmbiguous properties.

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.

using System;
using System.Globalization;
using Microsoft.Speech.Recognition;

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

    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();

        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();

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

See Also

Reference

SpeechRecognitionEngine Class

SpeechRecognitionEngine Members

Microsoft.Speech.Recognition Namespace