SpeechRecognitionEngine::UpdateRecognizerSetting Method (String^, Int32)
Updates the specified setting for the SpeechRecognitionEngine with the specified integer value.
Assembly: System.Speech (in System.Speech.dll)
Parameters
- settingName
-
Type:
System::String^
The name of the setting to update.
- updatedValue
-
Type:
System::Int32
The new value for the setting.
| Exception | Condition |
|---|---|
| ArgumentNullException | settingName is null. |
| ArgumentException | settingName is the empty string (""). |
| KeyNotFoundException | The recognizer does not have a setting by that name. |
With the exception of PersistedBackgroundAdaptation, property values set using the UpdateRecognizerSetting method remain in effect only for the current instance of SpeechRecognitionEngine, after which they revert to their default settings. See UpdateRecognizerSetting for descriptions of supported settings.
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.
Settings for recognizer MS-1033-80-DESK: ResourceUsage is not supported by this recognizer. ResponseSpeed = 150 ComplexResponseSpeed = 500 AdaptationOn = 1 PersistedBackgroundAdaptation = 1 Updated settings: ResourceUsage is not supported by this recognizer. ResponseSpeed = 200 ComplexResponseSpeed = 300 AdaptationOn = 0 PersistedBackgroundAdaptation = 0 Press any key to exit...
using System; using System.Globalization; using System.Speech.Recognition; namespace RecognizerSettings { class Program { static readonly string[] settings = new string[] { "ResourceUsage", "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("ResponseSpeed", 200); recognizer.UpdateRecognizerSetting("ComplexResponseSpeed", 300); recognizer.UpdateRecognizerSetting("AdaptationOn", 1); recognizer.UpdateRecognizerSetting("PersistedBackgroundAdaptation", 0); 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(); } } }
Available since 3.0