Wednesday, March 26, 2008

Text To Speech

Download and install the Microsoft Speech SDK
Create a new project in Visual Studio
Add a reference to the Microsoft Speech Object Library COM object
Use the following code to record your speech to a .wav file…


SpeechLib.SpFileStream SpeechFileStream;
SpeechFileStream = new SpeechLib.SpFileStreamClass();
SpeechFileStream.Open(@"c:\test.wav", SpeechLib.SpeechStreamFileMode.SSFMCreateForWrite, false);
SpeechLib.SpVoice spv = new SpeechLib.SpVoice();
spv.AudioOutputStream = SpeechFileStream;
spv.Speak("I'm alive!", SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault);
SpeechFileStream.Close();

No comments: