You are reading help file online using chmlib.com
|
Interface: ISpeechRecoContext
The Pause method pauses the engine object to synchronize with the speech recognition (SR) engine.
Pause stops the SR engine at a synchronization point to change grammars and rule states. A synchronization point occurs after any Recognition event, Bookmark event or as soon as possible after explicitly calling Pause. After synchronizing grammars and rule states, the engine continues recognizing if Resume is called.
After the application has changed the state or grammar, it should call ISpeechRecoContext.Resume. A call to Resume must be made for every call made to Pause. SAPI will automatically feed the buffered audio data into the SR engine, ensuring that no real-time audio data is lost and that the user experience is not interrupted. SAPI will restart the SR engine once Resume has been called.
During the pause, SAPI continues to collect and store audio input in an audio buffer. The SAPI audio buffer has a static limit to prevent SAPI applications or SR engines from consuming large amounts of system memory. If the speech recognition engine pauses too long, and the audio buffer fills, then a buffer overflow (SPERR_AUDIO_BUFFER_OVERFLOW) occurs. This would result in interruptions of other applications running SAPI. The buffer is set to 30 times the average bytes per second or approximately 30 seconds. Consequently, the audio data collected between the point when the buffer overflow occurred, and when the stream was reactivated, will be completely lost. Use Pause only for very short periods and call Resume immediately once grammars and rules states have changed.
SpeechRecoContext.Pause()
None.
Grammar and rule state changes can be requested while the SR engine is running. However, the changes will not take place until the engine stops and synchronizes. Since a Recognition event is a common synchronization point, in many situations, it may not be necessary to call Pause. However, if the grammar or state change needs to be implemented immediately, call Pause, make the change and then call Resume.
The SAPI 5 SR engine synchronizes close to every 60 seconds, which aids in timely shutdowns and avoids problems with loud and continuous background noises. There is no requirement for other manufacturer's engines to also synchronize like this although it is encouraged.
The following code snippet demonstrates uses Pause and Resume. The example code is Paused allowing the user to change the state or grammar.
Public WithEvents RC As SpSharedRecoContext
Set RC = New SpSharedRecoContext
'setup the recognition context
'...
'pause the context so that event notifications are not received
RC.Pause
'[quickly] perform the processing, as stated above
'...
RC.Resume
'applications will start receiving event notifications again
You are reading help file online using chmlib.com
|