Talking Computer Using Visual Basic.Net

This project I name this as “Talking Computer” because the program say’s the word(s) inputted by the user on the textbox provided. So let’s begin to do the project using visual basic. First Open Visual Basic->File->New Project->Write “Talking Computer” as name of our program.

Design Mode

Change the text of form into “Talking Computer” then add one label, one textbox and one button. Change the text property of label1 to “Your Text Here:” then change the Name property of textbox1 into “txtText” and on the button properties change the name into “btnClick” and the Text into “Click”. This is how it looks like:

Coding Mode

Next step were going to add a library for speech, to do this go to Solution Explorer and right click the project name->click Add Reference->Select Com tab-> choose Microsoft Speech Object Library like as shown below. And click Ok. Next Double click the form to show the Code Designer and above Public class add this code. Imports SpeechLib then, under public class add this code Dim speak As New SpVoice Then the designer will look like as shown below:
  1. Imports SpeechLib
  2. Public Class Form1
  3.  
  4.     Dim voice As New SpVoice
  5.  
  6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.  
  8.     End Sub
  9.  
  10. End Class
Next double click the btnClick button and add these bits of code. voice.Speak(txtText.Text) finally this is our code designer look like:
  1. Imports SpeechLib
  2. Public Class Form1
  3.  
  4.     Dim voice As New SpVoice
  5.  
  6.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.  
  8.     End Sub
  9.  
  10.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  11.         'in this single line of code it will preview the voice
  12.         'whatever the content of textbox based on the user input.
  13.         voice.Speak(txtText.Text)
  14.     End Sub
  15. End Class
Now were going to test our talking computer program just simply press f5 to run your program then on the textbox provided just type “hello world” and click ok. So as expected it will preview the corresponding voice based on the user input.

Comments

I liked the talk computer programs. Thanks.

Add new comment