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

ISpRecognizer::SetInput

ISpRecognizer::SetInput specifies which input stream the SR engine should use.

HRESULT SetInput(
   IUnknown  *pUnkInput,
   BOOL       fAllowFormatChanges
);

Parameters

pUnkInput
[in] The stream object token. See Remarks section.
fAllowFormatChanges
[in] Boolean indicating whether SAPI should try to change the input stream format to the engine's preferred format. This method can normally be set to TRUE; however, when performing both speech recognition and speech output at the simultaneously, some soundcards may require that both input and output are in the same audio format. Setting this to FALSE prevents the audio format on the input device from being changed. Instead, SAPI will try to convert the audio format itself to something the SR engine can use. 

Return values

Value Description
S_OK Function completed successfully.
E_INVALIDARG pUnkInput is invalid or not a stream.
SPERR_ENGINE_BUSY The current method cannot be performed while the engine is currently processing audio.
FAILED(hr) Appropriate error message.

Remarks

This method can be used to switch the input for the recognizer to a wave input stream, a different soundcard device, or to a custom audio object. The pUnkInput parameter can be a pointer to an object token representing an audio input device or a pointer to an actual object implementing ISpStreamFormat.

The input stream object will implement IStream, ISpStreamFormat, and ISpAudio for real-time streams. Applications should not use methods on these interfaces that actually change the state of the audio device or read data from it at the same time that the stream is being used by SAPI. For example, reading data from the application with IStream::Read will prevent the correct data from being passed to the SR engine. Altering the state of the audio using ISpAudio::SetState will put the audio device into an unexpected state and may cause errors. All control of the audio is done by SAPI.

When using the InProc recognizer, SAPI does not automatically setup the audio input. ISpRecognizer::SetInput must be called with a non-NULL pUnkInput to setup and start the audio input stream. Until ISpRecognizer::SetInput is called, methods such as ISpRecoGrammar::SetRuleState will return success code SP_STREAM_UNITIALIZED, but actual recognition will not start.

When using the shared recognizer, SAPI automatically sets up the audio input. However, ISpRecognizer::SetInput may be called with NULL as the pUnkInput parameter to force the recognizer to re-check the default audio input and re-set up the audio input (e.g., the default audio input object changes while recognizing, and the new audio input is to be used).

If the engine is currently processing audio, this call will fail with SPERR_ENGINE_BUSY.

Example

The following code snippet illustrates the use of ISpRecognizer::SetInput.

    // setup the inproc recognizer audio input with an audio input object token

    // get the default audio input token
    hr = SpGetDefaultTokenFromCategoryId(SPCAT_AUDIOIN, &cpObjectToken);
    // Check hr

    // set the audio input to our token
    hr = cpRecognizer->SetInput(cpObjectToken, TRUE);
    // Check hr
    // setup the inproc recognizer audio input with an audio input object

    // create the default audio input object
    hr = SpCreateDefaultObjectFromCategoryId(SPCAT_AUDIOIN, &cpAudio);
    // Check hr

    // set the audio input to our object
    hr = cpRecognizer->SetInput(cpAudio, TRUE);
    // Check hr
    // ask the shared recognizer to re-check the default audio input token
    hr = cpRecognizer->SetInput(NULL, TRUE);
    // Check hr - if SPERR_ENGINE_BUSY, then retry later


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