Share via


ISpPhrase::GetSerializedPhrase (Windows Embedded CE 6.0)

1/6/2010

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.).

Syntax

HRESULT GetSerializedPhrase(
  SPSERIALIZEDPHRASE** ppCoMemPhrase
);

Parameters

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

Return Value

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

Header sapi.h, sapi.idl
Library sapilib.lib
Windows Embedded CE Windows CE .NET 4.1 and later

See Also

Reference

ISpPhrase
SAPI Interfaces