ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

13-Text to Speech

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 Form1
    3.  
    4.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    5.         Dim speaks As New SpeechSynthesizer()
    6.  
    7.         speaks.Rate = 1
    8.         speaks.Volume = 100
    9.         speaks.Speak("Hi janobe")
    10.  
    11.     End Sub
    12. End Class
Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!