The .Net Framework 3.5 produce set of speech libraries for developing a Text-to-Speech. The System.Speech.Synthesis namespace provides a lot of classes for Text-to-Speech just like SpeechSynthesizer, VoiceInfo, InstalledVoice and many more.
Here’s the example on how to create a Text-to-Speech application:
- Open the Visual Basic, select “File” on the menu, hit new and create a new project.
- The New Project dialog will appear.
Select “windows” in the project types, hit the “windows form application” in the templates and name your project “TextToSpeech” then hit “ok“.
- Design the form this way. See it Below.
- You need to add System.Speech for the reference of the program.
- Double click the form and add this simple namespace for your imports.
Visual Basic1Imports System.Speech.Synthesis
- double click the button to fire the click event handler of it. Do the following code to declare and instantiate an
Visual Basic1Dim speaks As New SpeechSynthesizer()
- Call the
SpeakAsyncmethod of the object passing in a
stringcontaining the text we want to speak.
Visual Basic123speaks.Rate = 1speaks.Volume = 100speaks.Speak("Hi janobe")
- The code in the view code will look like this.
Visual Basic123456Imports System.Speech.SynthesisPublic Class Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim speaks As New SpeechSynthesizer()speaks.Rate = 1speaks.Volume = 100speaks.Speak("Hi janobe")End SubEnd Class
Readers might read also: