ISpSRAlternates::GetAlternates (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3


GetAlternates retrieves a list of alternate phrases.

SAPI calls GetAlternates when an application calls ISpRecoResult::GetAlternates. The alternate analyzer uses the SPPHRASEALTREQUEST information to generate at most, the requested number of alternate phrases, returned using the SPPHRASEALT pointer.

If the alternate analyze needs information that is not included in the phrase structure (see SPPHRASE), the speech recognition (SR) engine can store a custom, private block of data that is sent to the alternate analyze in the SPPHRASEALTREQUEST.pvResultExtra field. See also SPPARSEINFO.pSREnginePrivateData and SPPHRASE.pSREnginePrivateData.

The alternate analyzer communicates with the SR engine by retrieving the ISpRecoContext interface from the SPPHRASEALTREQUEST.pRecoContext field, and querying (see IUnknown::QueryInterface) for the SR engine's private extension (see ISpPrivateEngineCall).

HRESULT GetAlternates(
   SPPHRASEALT         **ppAlts,
   ULONG                *pcAlts


[in] Pointer to a structure of type, SPPHRASEALTREQUEST, which points to information about the alternate request (e.g., original phrase, number of alternates requested, private SR engine data, etc.).
[out] Pointer to a list of structures of type SPPHRASEALT for alternate phrases. The alternate analyzer uses the ISpPhraseBuilder interface to create the alternate phrases and return pointers to the alternates in the SPPHRASEALT.pPhrase field.
[out] The actual number of alternates in ppAltslist. The alternate analyzer returns the number of alternates it actually generated. If it cannot generate alternates for the original phrase, it should return zero. The number should be less than or equal to the number requested by the application (see SPPHRASEALTREQUEST.ulRequestAltCount).

Return values

S_OKFunction completed successfully.
FAILED (hr)Appropriate error message.