Text to Speech Application in VB.NET

How to make an application which Converts Text to Speech using VB.NET. Text to Speech program in VB.NET.

How to Create Text To Speech Application in Visual Basic (VB.NET)

This program in VB.NET converts an inputted text into a speech or voice. We will just only call the Speech API namespace for the program and with the use of SpVoice object. The SpVoice object brings the text-to-speech (TTS) engine capabilities to applications using SAPI automation. We can create numerous SpVoice objects, each one are independent 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.

Step 1 :

Open your visual studio > Go to File Menu > Click on New Project > Select Visual Basic windows Application > Name the Project Click on OK.

Step 2:

On Form1 change its name to Text to Speech. And drag and drop one Textbox and one Button on the form. Change the Textbox property to multi-line. Give the button name as Speak.

Form design:

Step 3:

double click on the Speak Button and write the below code.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim SAPI
        SAPI = CreateObject("SAPI.spvoice")  

End Sub


We have initialized a SAPI 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 tells what other outputs are available to the voice, and use another property to set its audio output to one of them. The SAPI.Speak method 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.

Step 4:

Now run the Application.


When we click on the button it will speak whatever the text you have entered in the Textbox in default system language. So here you can see how can we convert a Text into Speech using VB.NET.