How to Create a Talking Clock using Visual Basic (VB)
To start with, you will need to download and install the following.
- Microsoft Speech API.
- Microsoft Text to Speech Engine.
After installing the above API and Engine, you should be able to see an additional component installed on your VB Project components window.

Fig. 1
Now, that we have the required components installed. We can now start creating our talking clock.
Create a new project and select “standard exe” and click ok. You will then have the empty form.
Now, add the Text to Speech and a Timer components on your form, name the text to speech object to SpeakTime. (see Fig. 2)

Fig. 2
Are you still with me? Alright, lets proceed. Lets add now a text label on our form. (see Fig. 3)

Fig. 3
Alright, we’re almost there.
Click on the View Code button. Below is the working source code of the talking clock.
Option Explicit
Dim minCounter As Long
Dim secCounter As Long
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
Label1.Caption = Format(Now, “h:mm AM/PM”)
minCounter = Format(Now, “n”)
secCounter = Format(Now, “s”)
If minCounter = 0 And secCounter = 0 Then
speakTime.AudioReset
speakTime.Speak “The time now is., ” & Format(Now, “h:mm AM/PM”)
End If
End Sub

Thats all, you now have a simple working talking clock that tells time hourly.
Spread the word
del.icio.us Digg Furl Google StumbleUpon Technorati Windows Live Yahoo! Help



















Leave a Comment