ISpPhrase::GetSerializedPhrase (Windows CE 5.0)

Send Feedback

This method gets the phrase information in a serialized form. This would allow the client, for example, to save the phrase structure to a file, and later restore it by calling ISpPhraseBuilder::InitFromSerializedPhrase.

The caller passes in the address of a pointer which is initialized to point to a block of memory which is allocated using ::CoTaskMemAlloc. It is the caller's responsibility to call ::CoTaskMemFree to free this object. The structure retrieved is defined to be a SPSERIALIZEDPHRASE. However, the actual size of the block is contained in (*ppCoMemPhrase)->ulSerializedSize. This size includes the size of the SPSERIALIZEDPHRASE structure.

An application that will not need recognition alternates or retained audio may, and would like to save space, may want to serialize only the phrase information (for example, phrase text, rule name, SR engine identifier, and so on.).

HRESULT GetSerializedPhrase(SPSERIALIZEDPHRASE** ppCoMemPhrase);

Parameters

  • ppCoMemPhrase
    [out] Address of a pointer to an SPSERIALIZEDPHRASE structure containing the serialized phrase data.

Return Values

The following table shows the possible return values.

Value Description
S_OK Function completed successfully.
E_POINTER ppCoMemPhrase is invalid or bad.
SPERR_UNINITIALIZED Phrase is uninitialized.
E_OUTOFMEMORY Exceeded available memory.

Example

The following code snippet illustrates the use this method as inherited from ISpPhrase to serialize only the phrase portion of a result object.

HRESULT hr = S_OK;
// ... obtain a recognition result object from the recognizer...
SPSERIALIZEDPHRASE* pSerializedPhrase = NULL;
// get the recognized phrase object
hr = cpRecoResult->GetSerializdPhrase(&pSerializedPhrase);
// Check hr

Requirements

OS Versions: Windows CE .NET 4.1 and later.
Header: Sapi.h, Sapi.idl.
Link Library: Sapilib.lib.

See Also

ISpPhrase | SAPI Interfaces

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.