How do I develop batch applications that process speech?
Last reviewed: 7/15/2015
HOW Article ID: H061404
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");
// Instantiate ChantSR object
pChantSR = new CChantSR();
// Transcribe a file of recorded audio to text
pChantSR->StartRecording(L"myinaudiofile.wav");
// Instantiate ChantSR object
pChantSR = new CChantSR();
// Transcribe a file of recorded audio to text
pChantSR->StartRecording("myinaudiofile.wav");
// Instantiate ChantSR object
ChantSR1 := TChantSR.Create();
// Transcribe a file of recorded audio to text
ChantSR1.StartRecording('myinaudiofile.wav');
// Instantiate ChantSR object
JChantSR1 = new JChantSR();
// Transcribe a file of recorded audio to text
JChantSR1.startRecording("myinaudiofile.wav");
' 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);
// Instantiate ChantSR object
pChantSR = new CChantSR();
// Transcribe a file of recorded audio to text file
pChantSR->SpeechToText(L"myinaudiofile.wav", 0, CROFile, CAFDefault, L"Microsoft Speech Recognizer 8.0 for Windows (English - US)", L"Default Speech Profile", L"text", L"mytranscription.txt", CRRFile, CAFText, CRSAsynchronous);
// Instantiate ChantSR object
pChantSR = new CChantSR();
// Transcribe a file of recorded audio to text file
pChantSR->SpeechToText("myinaudiofile.wav", 0, CROFile, CAFDefault, "Microsoft Speech Recognizer 8.0 for Windows (English - US)", "Default Speech Profile", "text", "mytranscription.txt", CRRFile, CAFText, CRSAsynchronous);
// Instantiate ChantSR object
ChantSR1 := TChantSR.Create();
// Transcribe a file of recorded audio to text file
ChantSR1.SpeechToText('myinaudiofile.wav', 0, CROFile, CAFDefault, 'Microsoft Speech Recognizer 8.0 for Windows (English - US)', 'Default Speech Profile', 'text', 'mytranscription.txt', CRRFile, CAFText, CRSAsynchronous);
// Instantiate ChantSR object
JChantSR1 = new JChantSR();
// Transcribe a file of recorded audio to text file
JChantSR1.startRecording("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);
' Instantiate ChantSR object
NChantSR1 = new NChantSR()
' Transcribe a file of recorded audio to text file
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");
// Instantiate ChantTTS object
pChantTTS = new CChantTTS();
// Synthesize text to speech
pChantTTS->StartPlayback(L"Hello world.");
// Playback a wave file
pChantTTS->StartPlayback(L"myaudiofile.wav");
// Synthesize a file of text to speech
pChantTTS->StartPlayback(L"mytextfile.txt");
// Instantiate ChantTTS object
pChantTTS = new CChantTTS();
// Synthesize text to speech
pChantTTS->StartPlayback("Hello world.");
// Playback a wave file
pChantTTS->StartPlayback("myaudiofile.wav");
// Synthesize a file of text to speech
pChantTTS->StartPlayback("mytextfile.txt");
// Instantiate ChantTTS object
ChantTTS1 := TChantTTS.Create();
// Synthesize text to speech
ChantTTS1.StartPlayback('Hello world.');
// Playback a wave file
ChantTTS1.StartPlayback('myaudiofile.wav');
// Synthesize a file of text to speech
ChantTTS1.StartPlayback('mytextfile.txt');
// Instantiate ChantTTS object
JChantTTS1 = new JChantTTS();
// Synthesize text to speech
JChantTTS1.startPlayback("Hello world.");
// Playback a wave file
JChantTTS1.startPlayback("myinaudiofile.wav");
// Synthesize a file of text to speech
JChantTTS1.startPlayback("mytextfile.txt");
' 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);
// Instantiate ChantTTS object
pChantTTS = new CChantTTS();
// Synthesize text to speech and save to a wave file
pChantTTS->TextToSpeech(L"Hello world", L"Microsoft David Desktop - English (United States)", L"myaudiofile.wav", CPRFile, CAFDefault, CPSAsynchronous);
// Instantiate ChantTTS object
pChantTTS = new CChantTTS();
// Synthesize text to speech and save to a wave file
pChantTTS->TextToSpeech("Hello world", "Microsoft David Desktop - English (United States)", "myaudiofile.wav", CPRFile, CAFDefault, CPSAsynchronous);
var aTChantTTS: TChantTTS;
// Instantiate ChantTTS object
aTChantTTS = TChantTTS.Create();
// Synthesize text to speech and save to a wave file
aTChantTTS.TextToSpeech('Hello world', 'Microsoft David Desktop - English (United States)', 'myaudiofile.wav', CPRFile, CAFDefault, CPSAsynchronous);
// Instantiate ChantTTS object
JChantTTS1 = new JChantTTS();
// Synthesize text to speech and save to a wave file
JChantTTS1.startPlayback("Hello world", "Microsoft David Desktop - English (United States)", "myoutaudiofile.wav", ChantPlaybackResult.CPRFile, ChantAudioFormat.CAFDefault, ChantPlaybackStyle.CPSAsynchronous);
' 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)