13-Text to Speech

0
329

The .Net Framework 3.5 produce set of speech libraries for developing a Text-to-Speech. The System.Speech.Synthesis namespace provides lot of classes for Text-to-Speech just like SpeechSynthesizer , VoiceInfoInstalledVoice and many more.
Here’s the example on how to create Text-to-Speech application:

 

  1. Open the Visual Basic, select “File” on the menu, hit new and create a new project.
    01_helloworld
  2. The New Project dialog will appear.
    text2speech1
    Select “windows” in the project types, hit the “windows form application” in the templates and name your project “TextToSpeech” then hit “ok“.
  3. Design the form this way. See it Below.
    text2speech22
  4. You need to add System.Speech for the reference of the program.
    text2speech3
  5. Double click the form and add this simple namespace for your imports.
    1. Imports System.Speech.Synthesis
  6. double click the button to fire the click event handler of it. Do the following code to declare and instantiate a speech object .
    1. Dim speaks As New SpeechSynthesizer()
  7. Call the  SpeakAsync  method of the object passing in a string containing the text we want to speak.
    1. speaks.Rate = 1
    2. speaks.Volume = 100
    3. speaks.Speak("Hi janobe")
  8. The code in the view code will look like this.
    1. Imports System.Speech.Synthesis
    2. Public Class Form1Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    3. Dim speaks As New SpeechSynthesizer()speaks.Rate = 1
    4. speaks.Volume = 100
    5. speaks.Speak("Hi janobe")End Sub
    6. End Class

 

Readers might read also:

 

Facebook Comments
(Visited 36 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here