Engine Selection

After an application has identified a speech-recognition mode, it calls the Select member function to select the mode and create an engine object to represent that mode in the application. Both the ISRFind and ISREnum interfaces include the Select member function, and the syntax is the same for both.

When calling Select, the application specifies a globally unique identifier (GUID) that identifies the mode to use, the address of a variable that receives the address of the ISRCentral interface on the engine object, and the address of the IUnknown interface on the audio-source object created earlier (see "Introduction" earlier in this section).

When the Select member function is called, it ultimately creates an engine object. However, as the engine object initializes, it calls the IAudio interface on the audio-source object to determine whether or not the engine can use that audio source. If so, the engine object calls the IAudio::PassNotify member function, specifying the address of an IAudioSourceNotifySink interface so the audio-source object can notify the engine of events that pertain to incoming audio. If the engine cannot use the specified audio source, the ISREnum::Select member function returns an error and the engine object releases itself.

If successful, the Select member function returns the address of the ISRCentral interface on the newly created engine object. The ISRCentral interface provides centralized control of a speech-recognition engine, including loading a grammar, pausing and resuming the engine, getting information about the engine or the speech being received, and registering a notification sink. The engine uses the notification sink to notify the application of speech-related events.

The ISRCentral interface has the following member functions:

Member function

Description

GrammarLoad

Loads a grammar and returns a grammar object.

ModeGet

Retrieves information about the current speech-recognition mode.

Pause

Pauses the speech-recognition engine.

PosnGet

Retrieves the exact byte in the audio stream that the engine is currently receiving.

Register

Registers an ISRNotifySink interface with the engine, which uses the interface to pass status information to an application.

Resume

Resumes the speech-recognition engine.

ToFileTime

Converts a QWORD variable to a Win32 FILETIME structure.

UnRegister

Releases the ISRNotifySink interface that an engine used to pass status information to an application.


After obtaining the address of the ISRCentral interface on the engine object, the speech-recognition enumerator is no longer needed and the application should release it by calling the ISRFind::Release or ISREnum::Release member function. The application does not need to release the audio-source object because the engine automatically releases it when the engine object is released.