SpeechRecognizer Class
Provides access to the default shared speech recognition service available on the Windows Desktop.
Assembly: System.Speech (in System.Speech.dll)
Applications use SpeechRecognizer to implement a Windows Desktop Speech Technology client, using a system's default shared Technology as an out of process server.
Use of the SpeechRecognizer object is recommended for applications needing to process voice input received from through a desktop's standard audio input channels, such as a microphone.
Applications using SpeechRecognizer effectively do so through creating event handlers to receive audio recognition results, by controlling the grammars used, and by enabling or disabling recognition operations.
To support this, SpeechRecognizer provides programmatic control over:
-
The grammars are used by the application (see LoadGrammar, UnloadGrammar, UnloadAllGrammars, and Grammars for more information).
-
How recognition engine events, such as recognition or rejection of a phrase, are handled (see SpeechDetected, SpeechHypothesized, SpeechRecognitionRejected, SpeechRecognized, and LoadGrammarCompleted() for more information.
These recognition events are the means used by instances of SpeechRecognizer to return recognition results to applications.
-
Control and monitor the Windows Desktop Speech Technology recognition engine state (see Enabled, MaxAlternates, State, [P:System.Speech.Recognition.SpeechRecognizer.RecognizerInfoE:System.Speech.Recognition.SpeechRecognizer.RecognizerUpdateReached], StateChanged, AudioStateChanged, AudioSignalProblemOccurred, and AudioLevelUpdated))
-
Synchronizing and scheduling of configuration changes requested by a client application using members of used by an instance of SpeechRecognizer.
This is necessary because the Windows Desktop Speech Technology can be shared between multiple applications and process and running a different processes. (See PauseRecognizerOnRecognition, and RequestRecognizerUpdate for more information.)
-
Test an applications use of the Windows Desktop Speech Technology through emulation (see EmulateRecognize, EmulateRecognizeAsync, and EmulateRecognizeCompleted).
The configuration of the Windows Desktop Speech Technology on a system is managed through the Audio tab of the SpeechProperties member of the ControlPanel. This interface is used to select language, audio input device, and the default desktop speech recognition engine.
An instance of SpeechRecognizer makes use of the current configuration of the Windows Desktop Speech Technology on a system. If that configuration is changed while the application is running, (for instance if the recognition engine is disabled, or the language changed), that change will affect the use of SpeechRecognizer.
Applications requiring greater control over the Windows Desktop Speech Technology, or that require an in process recognition engine SpeechRecognitionEngine.
SpeechRecognizer implements [IDispose].
Under Windows XP Professional with Service Pack 2 (SP2), applications are limited to a single instance of SpeechRecognizer.
The example below shows the creation, initialization, and of a SpeechRecognizer object.
// Initializes the SystemRecognizer and loads sample grammars on form load.
private void Exerciser_Load(object sender, EventArgs eventArgs) {
// Initialize the DesktopRecognizer and event handlers.
_recognizer = new SpeechRecognizer();
// Disable recognition of grammars.
_recognizer.Enabled = false;
SetupEventHandlers();
LoadInitialGrammars();
_recognizer.PauseRecognizerOnRecognition = true;
}
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.