How Tos

Last reviewed: 7/15/2015

Article ID: H061404

HOW: Developing batch applications that process speech

The information in this article applies to:

  • SpeechKit 8

Summary

SpeechToText and TextToSpeech methods process speech with a new multi-tasking batch queue manager.

More Information

SpeechKit has split the StartRecording and StartPlayback methods into new methods: SpeechToText and TextToSpeech.

StartRecording retains the ability to transcribe from multiple audio source formats but returns text recognition events only. SpeechToText supports writing transcription results to files or streams and the can run in multiple worker threads if the speech engine supports.

StartPlayback retains its ability to synthesize text from a variety of source formats but only plays live audio. TextToSpeech supports writing audio to file and streams or returning audio bytes and can run in multiple worker threads if the speech engine supports.

The following examples illustrate using the StartRecording method to transcribe from an audio file.

// Instantiate ChantSR object
NChantSR1 = new NChantSR();

// Transcribe a file of recorded audio to text
NChantSR1.StartRecording("myinaudiofile.wav");

The following examples illustrate using the SpeechToText method to transcribe from an audio file and write the results to a text file.

// Instantiate ChantSR object
NChantSR1 = new NChantSR();

// Transcribe a file of recorded audio to text
NChantSR1.SpeechToText("myinaudiofile.wav", 0 ChantRecordingObject.CROFile, ChantAudioFormat.CAFDefault, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "Default Speech Profile", "text", "mytranscription.txt", ChantRecordingResult.CRRFile, ChantAudioFormat.CAFText, ChantRecordingStyle.CRSAsynchronous);

The following examples illustrate using the StartPlayback method to synthesize speech and playback audio.

// Instantiate ChantTTS object
NChantTTS1 = new NChantTTS();

// Synthesize text to speech
NChantTTS1.StartPlayback("Hello world.");

// Playback a wave file
NChantTTS1.StartPlayback("myinaudiofile.wav");

// Synthesize a file of text to speech
NChantTTS1.StartPlayback("mytextfile.txt");

The following examples illustrate using the TextToSpeech method to synthesize speech to an audio file.

// Instantiate ChantTTS object
NChantTTS1 = new NChantTTS();

// Synthesize text to speech and save to a wave file
NChantTTS1.TextToSpeech("Hello world", "Microsoft David Desktop - English (United States)", "myoutaudiofile.wav", ChantPlaybackResult.CPRFile, ChantAudioFormat.CAFDefault, ChantPlaybackStyle.CPSAsynchronous);