How Tos

Last reviewed: 4/30/2008

Article ID: H040801

HOW: Recording audio with console applications

The information in this article applies to:

  • SpeechKit 5, 6


Console applications do not have windows and are unable to use Windows Multimedia functions. Therefore you can't use the ChantAudio StartRecording method to record audio. To develop console applications that record audio, you need to use low-level audio processing handlers.

However, within SpeechKit 5, you can Nuance Vocon 3200 to record audio to buffers, streams, or files.

More Information

The ChantSR StartRecording method has been updated to provide a way to record audio without requiring any recognition.

Enabling a Nuance L&H BNF grammar with no rules allows the VoCon 3200 recognizer to run without the any recognition occurring. The audio can be captured and returned in buffers, written to a stream, or file as requested via the ChantSR StartRecording method. The ChantSR StopRecording terminates the process of returning audio. The code would look something like:

int _tmain(int argc, _TCHAR* argv[])
m_pChantSR = new CChantSR(TRUE);

// Set deployment license properties

// Set VoCon 3200 as the default recognizer (Modify paths to point to your SDK and acooustic model file)
m_pChantSR->SetNumberProperty(CNPEngineAPI, (int)CEVoCon3200);
m_pChantSR->SetStringProperty(CSPEnginePath, L"c:\\Program Files\\ScanSoft\\Vocon3200\\EDS_v2_2\\bin\\winx86rel_utf16_fs16");
m_pChantSR->SetStringProperty(CSPAcousticModel, L"c:\\Program Files\\ScanSoft\\Vocon3200\\EDS_v2_2\\bin\\winx86rel_utf16_fs16\\vocon3200lngenu_full.dat");

// Define grammar vocabulary
int GrammarVocabID = m_pChantSR->DefineResource(CSRGrammarVocab, L"c:\\empty.bnf");
// Enable grammar vocabulary
EnableResource(CSRGrammarVocab, GrammarVocabID);

::wprintf(L"Recording started...");

// Record 5 seconds

::wprintf(L"Recording stopped.");
// Disable command vocabulary
DisableResource(CSRGrammarVocab, GrammarVocabID);

// Destroy the ChantSR object
delete m_pChantSR;
m_pChantSR = NULL;

return 0;

Create a grammar file empty.bnf with the following contents:

#BNF+EM V1.0;
!grammar empty;

You can also retain audio during recognition. In this case, you use grammars with rules. Your application receives recognition events in addition to the audio used during recognition.