ISpeechRecognizer Interface

Microsoft Speech SDK

Intelligent Interface Technologies Home Page Microsoft Speech SDK

Speech Automation 5.1

ISpeechRecognizer

The ISpeechRecognizer automation interface represents a speech recognition engine.

A recognizer is a speech recognition (SR) engine. Engines are generally categorized by two major characteristics. The first is the language of the engine. The language is provided by the manufacturer and may not be changed. A computer may have several types of engines installed at the same time. However, the use of the engine is limited and is dependent of the recognition type. The second major characteristic is the recognition type, that is, whether the instance of the engine is created as in-process (also known as InProc) or shared. See Recognition Types for more information.

A default SR engine is selected using Speech properties in Control Panel. This is provided as a convenience to users and the default engine will be used if no other type is explicitly specific. In many cases, users requirements can be met by a single engine. However, applications are not restricted to the default engine and may use other engines as needed. In contrast, an active engine is one that is instantiated and being used by at least one recognition context.

More than one instance of an engine may used. Each application may have its own instance of a recognizer and in some situations, each recognition context may have its won engine instance. Application using InProc recognizers must have their own instance. If greater granularity is needed for recognition, it is recommended to use different recognition contexts rather than using multiple recognizers.

The following code snippet declares a shared recognition context and an implicit shared recognizer.

Public WithEvents RC As SpSharedRecoContext
Set RC = New SpSharedRecoContext

However, there are cases when a recognizer may be needed prior to declaring a recognition context. To do so, declare the recognizer in the standard fashion.

Dim SharedRecognizer As SpSharedRecognizer
Set SharedRecognizer = CreateObject("SAPI.SpSharedRecognizer")

Recognition Types

A recognition engine can be created with one of two types: Inproc and shared. The first, InProc, is within the same process as the application. An InProc recognizer restricts access to only that one application. For example, an InProc recognizer would prohibit other applications from using the system microphone. While other applications could run their own instance of an InProc recognizer, no resource could be common among them. An InProc engine may be used, for example when recognizing from a wav file. In fact, a shared engine may not use wav files for input.

The second type of recognizer is the shared recognizer. It is run is as a separate process from the application. As a result, other applications may use the engine's resources at the same time. For instance, the same system microphone will be used by all open applications. In turn, the resulting recognition from the engine may be used by any of the applications. In fact, shared engines go so far as to actually inform applications when a recognition result is not applicable to them.

For shared engines, a recognizer instance is created automatically when a recognition context is created. In this case, the type of recognizer will be the same as the type of recognition context. That is, a shared recognition context will create a shared recognizer of the same type as the active engine. However, all applications using a shared engine must create instances of that engine type. One application may not use one shared engine and a second application use another engine type.

InProc engines are similarly created in that an InProc engine instance is created when an InProc recognition context is created. InProc engine instances may be created separately. Each application may have only one InProc engine instance active at time. However, while an application can only have one InProc engine instance at a time, different applications, even if open at the same time, may each have a different engine active. For example, one application may be using an InProc English engine and another application may be recognizing from a Chinese engine.

Regardless, recognizers and recognition contexts must be the same type. If a recognizer is created as a shared resource, resulting recognition contexts associated with that recognizer must also be shared. The same is true for InProc recognizers and recognition contexts. See Recognition Event for an example. In addition, the recognition context is declared and created without having to declare the recognizer explicitly.


Automation Interface Elements

The ISpeechRecognizer automation interface contains the following elements:


Properties Description
AllowAudioInputFormatChangesOnNextSet Property Specifies whether the recognizer can change audio input formats on subsequent audio streams.
AudioInput Property Gets and sets the recognizer's audio input device.
AudioInputStream Property Gets and sets the recognizer's audio input stream.
IsShared Property Indicates whether a recognition engine is shared or InProc.
Profile Property Specifies the recognizer's current recognition profile.
Recognizer Property Specifies characteristics about the active recognizer.
State Property Returns the current state of the recognition engine.
Status Property Returns an object representing the status of the recognizer.
Methods Description
CreateRecoContext Method Creates a recognition context object from the recognizer.
DisplayUI Method Initiates the display of the specified UI.
EmulateRecognition Method Emulates recognition from a textual source rather than from a spoken source.
GetAudioInputs Method Returns a selection of the available audio input devices.
GetFormat Method Returns the current input audio format.
GetProfiles Method Returns a selection of the available user speech profiles.
GetPropertyNumber Method Returns a numeric value specified by the named key.
GetPropertyString Method Returns the string value corresponding to the specified key name.
GetRecognizers Method Returns a selection of SpeechRecognizer objects in the speech configuration database.
IsUISupported Method Determines if the specified UI is supported.
SetPropertyNumber Method Sets a numeric property corresponding to the specified name.
SetPropertyString Method Sets a text property corresponding to the specified name.