ISREnum::Select

HRESULT Select(GUID gModeID, PISRCENTRAL *ppiSRCentral,

PIUNKNOWN pIUnknownForAudio);

Selects a speech-recognition mode and creates an engine object to represent the selected mode.

· Returns NOERROR if successful, or one of these error values:

E_INVALIDARG
E_OUTOFMEMORY
SRERR_INVALIDMODE
SRERR_OUTOFDISK
SRERR_WAVEFORMATNOTSUPPORTED

gModeID

[in] GUID from the SRMODEINFO structure for the speech-recognition mode that is selected. The function creates an engine object to represent this mode.

ppiSRCentral

[out] Address of a variable that receives a pointer to the ISRCentral interface for the newly created engine object.

pIUnknownForAudio

[in] Address of the IUnknown interface for the audio-source object that provides digital-audio data for the engine object. The engine will AddRef the interface, and release the interface when the engine is destroyed. Because of this the application will need to call Release on the audio object after the select call or audio objects will be leaked.

After the application enumerates the speech-recognition modes and determines which one to use, it calls the Select member function to create the engine object.

As the engine object initializes, it calls the IAudio interface on the audio-source object specified by pIUnknownForAudio to determine whether or not it can use that audio source. If so, the member function returns an ISRCentral interface for the newly created engine object. If not, the engine object releases itself and the Select member function returns an error.

After the engine object is created, it calls the IAudio::PassNotify member function to pass its own notification sink to the audio-source object so that object notifies the engine when audio data is available. When all references to the engine object are released, the object calls the IAudio::Release member function.

The multimedia audio-source object can be used to obtain audio from a wave-in device. The Select member function call passes the IUnknown interface rather than the IAudioSource interface because, although all engines should support IAudioSource, some engines may talk to custom interfaces for dealing with special hardware or drivers and IUnknown can be used to obtain such interfaces. For more information about the multimedia audio-source object, see the section, "Multimedia Audio Objects ."

The pIUnknownForAudio parameter is obtained by using the CoCreateInstance function. As such, the reference count for the IUnknown interface begins at 1, and the interface should be released after the Select member function has returned.

The negotiation with the audio-source object occurs within the Select call, so if Select returns without an error, then the negotiation succeeded.