How to Convert Text Input to Speech Output

Submitted by: 
Visitors have accessed this post 2100 times.

How to convert text input to speech output

The usage of text to speech is been increasing day by day, one of the main applications are automatic birthday wish speaker. VB.NET provides simple steps to convert text to speech, they are

1) Import the text to speech library
2) Create a SpeechSynthesizer instance
3) Use speak method.

Explanation

1) Import the text to speech library

.net framework provides few classes to support text to speech functionalities in the assembly called System.Speech.Synthesis. to import this library, just go to project->add reference. Under the add reference dialog, choose the .NET tab and add the System.Speech assembly.

Once it is done, just import the assembly like,
Imports System.Speech.Synthesis


2) Create a SpeechSynthesizer instance

SpeechSynthesizer is a class which is ment for converting the text into voice. So lets create an instance of the class SpeechSynthesizer.
Dim a As New SpeechSynthesizer

3) Use Speak method

a.speak(“your text”)

How to speak in background?
When you use the speak() methid, you will notice that the application hangs until the speech is over. To eliminate this, there is one more method called SpeakAsync() which speaks in background. This method is much useful when the text is very long, and there are lots of parallel activities that needs to be done.
a.SpeakAsync (“your text”)

How to change volume of the speech?
There is an attribute called as Volume, this is used to set the volume of the speech.
a.volume=94

NOTE: Volume must always be between 0 to 100.

How to change the rate of speech?
Sometimes it is necessary to increase/decrease the speed of speech. This can be done by rate attribute.
a.rate=9
NOTE: rate must always between -10 to 10.


Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.

Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.

FOR YOUR OWN SAFETY, PLEASE:

1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.