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

ISpRecoResult::ScaleAudio

ISpRecoResult::ScaleAudio converts an existing audio stream into a different audio format.

HRESULT ScaleAudio(
  const GUID           *pAudioFormatId,
  const WAVEFORMATEX   *pWaveFormatEx
);

Parameters

pAudioFormatId
[in] Address of the data format identifier. Typically, this value is SPDFID_WaveFormatEx.
pWaveFormatEx
[in] Address of the WAVEFORMATEX structure that contains the audio format to convert to. This value must be NULL if pAudioFormatId is not specified as SPDFID_WaveForamtEx.

Return values

Value Description
S_OK Function completed successfully.
E_INVALIDARG Either pAudioFormatId or pWaveFormatEx is invalid or bad.
SPERR_NO_AUDIO_DATA Audio stream is unavailable.
SPERR_UNSUPPORTED_FORMAT The engine format is non-waveformatex and the retained format the same format.
E_OUTOFMEMORY Exceeded available memory.
FAILED(hr) Appropriate error message.

Remarks

Use the ISpPhrase::Discard method to completely discard audio data associated with a result object.

The application can also set the default retained audio format for the ISpRecoResult object by calling ISpRecoContext::SetAudioOptions. Calling ::SetAudioOptions will only apply to all subsequent recognitions, not the current ISpRecoResult object.

When performing a scaling with a compressed format, it is possible to introduce small rounding errors, since the content of the audio is not used to perform the conversion.

Scaling between certain compressed formats is not supported by the SAPI format converter (See the Remarks section for ISpStreamFormatConverter).

Example

The following code snippet illustrates the use ISpRecoResult::ScaleAudio to scale the audio to a low quality format before serialization to the disk (to save space).

    HRESULT hr = S_OK;

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

    // create a format helper with a very low quality format 
    CSpStreamFormat ScaleFormat(SPSF_8kHz8BitMono, &hr);
    // Check hr

    hr = cpRecoResult->ScaleAudio(&(ScaleFormat.FormatId()), ScaleFormat.WaveFormatExPtr());
    // Check hr

    // get a result serialization pointer
    SPSERIALIZEDRESULT* pSerializedResult;

    // serialize the result
    hr = cpRecoResult->Serialize(&pSerializedResult);
    // Check hr

    // ... write pSerializedResult to the disk

Development Helpers

Helper Enumerations, Functions and Classes Description
SPSTREAMFORMAT SAPI supported stream formats
CSpStreamFormat Class for managing SAPI supported stream formats and WAVEFORMATEX structures


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