Skip to main content

How to Create a Text-To-Speech Application in VB.NET

Screenshot
Body

This is my another tutorial in VB.NET that converts an inputted text into a speech or voice. We will just only call the Speech API namespace for this program and with the use of Spvoice object. The SpVoice object brings the text-to-speech (TTS) engine capabilities to applications using SAPI automation. An application can create numerous SpVoice objects, each independent of and capable of interacting with the others. A SpVoice object usually referred to simply as a voice, is created with default property settings so that it is ready to speak immediately.

So, now let's start this tutorial!
  1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application.
  2. Next, add one TextBox named TextBox1 for inputting a text to become a speech, and add one button named Button1 to convert the inputted text into speech. Design your layout like this one below:
    design
  3. Put this code to your Button1_Click. This will trigger to speak your inputted text.
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2. Dim tts = CreateObject("SAPI.spvoice")
    3. tts.speak(TextBox1.Text)
    4. End Sub

Explanation:

We have initialized a tts variable to create an object of SAPI.spvoice. A SAPI.spvoice is created with its audio output set to the system default audio output. It also determines what other outputs are available to the voice, and use another property to set its audio output to one of them.

The Speak method here places a text stream in the TTS engine's input queue of our inputted text in TextBox1 and returns a stream number. It can be called synchronously or asynchronously. When called synchronously, the Speak method returns immediately, and the voice speaks as a background process.

Output:

Click the button to speak the inputted text.
output

DEMO

You can also download the source code below and try it! :)

For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.

Best Regards,

Engr. Lyndon R. Bermoy
IT Instructor/System Developer/Android Developer
Mobile: 09079373999
Telephone: 826-9296
E-mail:[email protected]

Visit and like my page on Facebook at: Bermz ISware Solutions

Subscribe at my YouTube Channel at: SerBermz

Visit my website at: CampCodes

Add new comment