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

ISpMMSysAudio::Read

ISpMMSysAudio::Read reads the data from the multimedia audio device.

The audio device should not be directly manipulated when performing speech recognition (see ISpRecognizer).


HRESULT Read(
   void    *pv,
   ULONG    cb,
   ULONG   *pcbRead 
);

Parameters

pv
[in] Pointer to the buffer into which the stream data is read. If an error occurs, this value is NULL.
cb
[in] Specifies the number of bytes of data to attempt to read from the audio device.
pcbRead
[out] Pointer to a ULONG variable that receives the actual number of bytes read from the stream object. If set to NULL, no byte value is passed back.

Return values

Value Description
S_OK Function completed successfully.
SPERR_AUDIO_BUFFER_OVERFLOW SAPI's internal audio buffer has filled, and the device has been closed. See Remarks section.
SPERR_AUDIO_BUFFER_UNDERFLOW The multimedia object has not received audio data from the device quickly enough, and the device has been closed. See Remarks section.
SPERR_AUDIO_STOPPED Multimedia device state has been set to stopped.
E_OUTOFMEMORY Exceeded available memory
E_POINTER At least one of pcbRead or pv are invalid or bad.
STG_E_ACCESSDENIED Multimedia device is read-only and no bytes will be read. Error will occur when reading from an output device.
FAILED (hr) Appropriate error message.

Remarks about audio buffer overflows and underflows

SAPI automatically stores data in a buffer before it is read from the device. Buffering the audio data ensures that applications and SAPI-compliant speech recognition engines will not lose real-time audio data.

An errant application or speech recognition engine that does not call Read often enough could frequently fill the audio buffer. To ensure that large amounts of system memory are not filled, SAPI limits the buffer size to 30 times the average bytes per second (WAVEFORMATEX->nAvgBytesPerSec)- approximately 30 seconds. If the audio buffer is filled, SAPI will automatically set the device state to SPAS_CLOSED (see SPAUDIOSTATE) and return a buffer overflow error (i.e., SPERR_AUDIO_BUFFER_OVERFLOW) when ISpMMSysAudio::Read is called.

An errant multimedia device (and/or driver) that does not return audio data quickly enough could greatly reduce the speed of a speech application or SR engine. To prevent the degradation of application or SR engine performance, SAPI requires that the multimedia device return data at least once every five seconds. If the audio is not returned before five seconds, SAPI will automatically set the device state to SPAS_CLOSED (see SPAUDIOSTATE) and return a buffer underflow error (i.e., SPERR_AUDIO_BUFFER_UNDERFLOW) when ISpMMSysAudio::Read is called.

Applications should manually reopen the audio device (see ISpAudio::SetState) to prevent losing input data that could impact the user.

For SR engines, SAPI automatically attempts to restart the multimedia device after the SR engine exits ISpSREngine::RecognizeStream.



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