Windows SAPI is a nice tool that comes with Windows that allows us to transform an input text into a speech.
Ok, this is quite simple…takes only 3 lines of code, so not much explanation is needed.
Right click on the project’s name (in Solution Explorer)->Add Reference->COM and look for Microsoft Speech Object Library, select it then click Ok.
Now include the following line, near the first lines of code (where the namespaces are included):
1 using SpeechLib;
Double click on the button we created before - this will create a new method, in which we’ll add the code that converts text to speech:
1 2 3 4 string helloString = "Hello World"; SpVoice voice = new SpVoice(); voice.Speak(helloString, SpeechVoiceSpeakFlags.SVSFDefault); // tries to spell "Hello World"