Share via


Note

Please see Azure Cognitive Services for Speech documentation for the latest supported speech solutions.

Microsoft Speech Platform

ISpPhrase::GetSerializedPhrase

ISpPhrase::GetSerializedPhrase returns the phrase information in serialized form.

<pre IsFakePre="true" xmlns="http://www.w3.org/1999/xhtml"> <strong>HRESULT GetSerializedPhrase(</strong><a runat="server" href="jj127885(v=msdn.10).md"><strong>SPSERIALIZEDPHRASE</strong></a> **<em>ppCoMemPhrase</em> ;) </pre>

Parameters

  • ppCoMemPhrase
    [out] Address of a pointer which will be initialized to point to the serialized phrase data. The block of memory is created by CoTaskMemAlloc and must be manually freed with CoTaskMemFree when no longer needed.

Return Values

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

Remarks

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 returned 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 and needs to save space, can serialize only the phrase information (such as phrase text, rule name, speech recognition engine ID, or other information associated with a recognized phrase) by calling ISpPhrase::Discard.

Example

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

`

// Declare local identifiers:
HRESULT                   hr = S_OK;
CComPtr<ISpRecoResult>    cpRecoResult;
SPSERIALIZEDPHRASE        *pSerializedPhrase = NULL;

// ... Obtain a recognition result object from the recognizer ...

// Get the recognized serialized phrase object. hr = cpRecoResult->GetSerializdPhrase(&pSerializedPhrase;);

if (SUCCEEDED (hr)) { // Do something with it. }

`