Text to Speech is back   

 
Last weekend I had great surprise (and probably a first). I tried to a text to speech prototype I set up in 2005 and it worked flawlessly! No missing assemblies or weird errors. Here is a TTS sample where you can type text and hear it right away! I used the SPVoice object of the Microsoft Speech Library. To be honest I set this up for a demo but never found a productive way of using it. There are some web sites out there that offer this as a service now.

Unfortunately the voices are pretty monotonous. Hearing a long speech becomes unbearable, but it could be useful for a custom captcha application maybe. The voices offered by Cepstral are pretty decent and affordable.

What is truly surprising is how easy it is to use. See sample below.

 SpeechLib Sample

SpeechLib.SpVoice VoiceObject = new SpeechLib.SpVoiceClass();

SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFDefault;

// Get the first voice -- You can install more than one
VoiceObject.Voice = VoiceObject.GetVoices(null, null).Item(0);

// This only works in windows app.  
// The sound will be played using the default output device           
VoiceObject.Speak(thetext, SpFlags);
            
//This is a sample to save the audio to a file
SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite;

SpFileStream SpFileStream = new SpFileStream();
                                
SpFileStream.Open(filepath, SpFileMode, false);

VoiceObject.AudioOutputStream = SpFileStream;

VoiceObject.Speak(thetext, SpFlags);
                
VoiceObject.WaitUntilDone(-1);
                
SpFileStream.Close();
                
SpFileStream = null;
                
VoiceObject = null;

 Say it!

Published  on  8/7/2009  by  xsolon
0  Comments  |  Trackback Url  | 0  Links to this post | Bookmark this post with:          
Tags: | Categories:
Technorati Tags:
 

Links to this post

Comments

Title:
Receieve Notification:
Website:
Email:
Comments:

CAPTCHA Image Validation