We will start by opening a new project in Visual Studio 2010(or previous versions). We will name our project "TextToSpeech" as shown in the picture below.
We will now add a Label, Text box and a button. Change the text property of label to "Please enter text and I will Speak it for you". Change the multiline property of the text box to true and change the text of the button to "Speak".
VB.net
Dim speech As New SpeechLib.SpVoice
speech.Speak(TextBox1.Text, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault)
C#
SpeechLib.SpVoice speech = New SpeechLib.SpVoice;
speech.Speak(TextBox1.Text, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault);
Now Debug the the program to make sure it works properly. write any thing in the text box and click the speak button and the computer will speak what you enter.
No comments:
Post a Comment