Record and playback compressed audio

Last reviewed: 9/10/2008

HOW Article ID: H090814

The information in this article applies to:

  • SpeechKit 6


The ChantAudio component provides a simple way to record and playback wave audio from/to buffers, files, and streams.

With SpeechKit 6, you can record and playback compressed audio formats.

More Information

The ChantAudio component serves as a helper class to manage wave audio and audio devices on your system.

In SpeechKit 6, the ChantAudio component now supports Microsoft's DirectShow API to playback and record compressed audio formats.

For audio playback, the audio rendering objects in DirectShow attempt to find the appropriate audio filter (codec) for the file type. If Windows Media Player is installed, you likely can playback .wma and .mp3 files as illustrated in the following example:

// Playback the file
ChantAudio.StartPlayback(-1, "c:\\pathtomyfile\\myinaudiofile.wma", CPSAsynchronous)
// When done, release the resources. Use CCDAudioStop event for knowing when playback is done.

// Record audio
ChantAudio.StartRecording(-1, "c:\\pathtomyfile\\myoutaudiofile.wma", CRRFile, CAFDefault);
// When done, stop recording and release the resources

For recording compressed audio, the ChantAudio component automatically generates a profile that best matches the requested audio format.

The ChantAudio methods are not queued. If you want take advantage of the ChantTTS queue for scheduling playbacks, then invoke your playback via the ChantTTS StartPlayabck method as illustrated in the following example:

// Playback the file
// No need to StopPlayback when playback done since ChantTTS queue manager handles automatically at end of playback.