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.
1Imports System.Speech.Synthesis - double click the button to fire the click event handler of it. Do the following code to declare and instantiate an
speech
object.
1Dim speaks As New SpeechSynthesizer() - Call the
SpeakAsync
method of the object passing in astring
containing the text we want to speak.
123speaks.Rate = 1speaks.Volume = 100speaks.Speak("Hi janobe") - The code in the view code will look like this.
123456Imports 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: