CHMlib Logo Leading Translation Management System for Translation Agencies, Top Translation Management Software for Freelance Translators, Time Tracking Software, Word Count, Character Count and Line Count Software, Computer Assisted Translation Tool for Easy Word Count, Clipboard Character Count Software, User-Friendly Translation Memory Software, Terminology Management Software, Terminology Management Server, Microsoft Glossary Software, Dictionary of Acronyms, Social Network for Translators and Translation Agencies, Acronyms and Abbreviations Search Engine, Russian Translation Lab, Ukrainian Translation Lab.
You are reading help file online using chmlib.com
CrisisHelper - First Aid in Tough Times of World Economic Crisis


The Microsoft.com Speech website Microsoft Speech SDK

SAPI 5.1

ISpRecoContext::DeserializeResult

ISpRecoContext::DeserializeResult creates a new result object from a serialized result.

HRESULT DeserializeResult(
   const SPSERIALIZEDRESULT  *pSerializedResult,
   ISpRecoResult            **ppResult
);

Parameters

pSerializedResult
[in] Pointer to a serialized result. See also SPSERIALIZEDRESULT
ppResult
[out] The unserialized result object. The application must call IUnknown::Release when finished using the ISpRecoResult reference.

Return values

Value Description
S_OK Function completed successfully.
E_INVALIDARG pSerializedResult is invalid or bad.
E_POINTER ppResult is invalid or bad.
E_OUTOFMEMORY Exceeded available memory.
FAILED(hr) Appropriate error message.

Remarks

After deserializing the ISpRecoResult object, the application can retrieve alternates for the RecoResult, retrieve the retained audio, or examine the recognition.

The same SR engine that was originally used to generate the ISpRecoResult object (or recognition) must be the same SR engine that is associated with the ISpRecoContext that called ::DeserializeResult (see SPPHRASE.SREngineID). The SR engine requirement ensures that the SR engine is capable of recognizing the original phrase, and that it understands any SR engine private result data (see SPPHRASE.ulSREnginePrivateDataSize).

Example

The following code snippet illustrates the use ISpRecoContext::Deserialize a previously serialized result object.

    HRESULT hr = S_OK;

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

    SPSERIALIZEDRESULT* pSerializedResult = NULL;
    ULONG cbWritten = 0;
    ULONG ulSerializedSize = 0;
    LARGE_INTEGER liseek;
    LARGE_INTEGER li;
    CComPtr<IStream> cpStreamWithResult;

    hr = CreateStreamOnHGlobal(NULL, true, &cpStreamWithResult);
    // Check hr

    // Serialize result to memory
    hr = cpRecoResult->Serialize(&pSerializedResult);
    // Check hr

    //serialized to a stream pointer
    hr = cpStreamWithResult->Write(pSerializedResult, pSerializedResult->ulSerializedSize, &cbWritten);
    // Check hr

    // free the serialized result
    if (pSerializedResult) ::CoTaskMemFree(pSerializedResult);

    // commit the stream changes
    hr = cpStreamWithResult->Commit(STGC_DEFAULT);
    // Check hr

    // ... persist stream to disk, network share, etc...
    // ... shutdown application .... 

    // ... restart application and get the persisted stream

    // reset the stream seek pointer to the start before deserialization
    li.QuadPart = 0;
    hr = cpStreamWithResult->Seek(li, STREAM_SEEK_SET, NULL);
    // Check hr

    // find the size of the stream
    hr = cpStreamWithResult->Read(&ulSerializedSize, sizeof(ULONG), NULL);
    // Check hr

    // reset the seek pointer
    liseek.QuadPart = 0 - sizeof(ULONG);
    hr = cpStreamWithResult->Seek(liseek, STREAM_SEEK_CUR, NULL);
    // Check hr

    // allocate the memory for the result
    pSerializedResult = (SPSERIALIZEDRESULT*)::CoTaskMemAlloc(ulSerializedSize);
    // Check pSerializedResult in case out "out-of-memory"

    // copy the stream into a serialized result object
    hr = cpStreamWithResult->Read(pSerializedResult, ulSerializedSize, NULL);
    // Check hr

    // Deserialize result from memory
    hr = cpRecoContext->DeserializeResult(pSerializedResult, &cpRecoResultNew);
    // Check hr

    // free the pSerializedResult memory
    if (pSerializedResult) {
        CoTaskMemFree(pSerializedResult);
    }

    // As long as the same engine was used to generate
    // the original result object, as is now being used,
    // applications can now get alternates for the cpRecoResultNew's phrase


You are reading help file online using chmlib.com

If you want your help file to be removed or added please send e-mail to chmlibcom@gmail.com
Partner sites: Logo Design, Simple Anti-Crisis Accounting Software, Voice Search for Web