Understanding Stuff

How to make your Windows Computer Talk

 

This is a fun experiment to make any Microsoft Windows computer talk to you.  It uses something built into Windows called Visual Basic.  This allows you to write a small program (called a "script") with instructions that make your PC say some words.

  1. First, we shall create the script with the Notepad program.  Point the bottom-left of your computer screen and click on the Windows icon and type notepad.  Then click on the Notepad app to start it.

  2. Type the following (or copy-and-paste) EXACTLY as shown into the Notepad window:
    Set Speak = CreateObject("sapi.spvoice")
    Speak.Rate = 0
    Speak.Volume = 100
    Speak.Speak "Hello. I am the computer and I am pleased to meet you."

  3. Next, we need to save this script to your computer.  Click on File (at the top-left of your Notepad window) and select Save.

  4. In the Save window, click on Desktop and then change Save as type: to All Files (*.*) and change the File name: to say.vbs

  5. Close down the Notepad window.

  6. Double click on your new desktop icon say and listen.

  7. To edit your script and make changes:
    • Right-click on your new icon
    • Select Edit, make your changes and FileSave, then close down Notepad.
    • Continue from instruction 6 (above).

Try these examples

An input box

Dim Message
Message = InputBox("Please enter some text","Speak")
Set Speak = CreateObject("sapi.spvoice")
Speak.Rate = 0
Speak.Volume = 100
Speak.Speak Message

Using the Date and time

Dim Message
Set Speak = CreateObject("sapi.spvoice")
Speak.Rate = 0
Speak.Volume = 100
Message = "The time is " & Time
Speak.Speak Message
Message = "The date is " & Date
Speak.Speak Message
Message = "The date and time is " & Time & " " & Date
MsgBox(Message)

And more...

Dim Message
Dim Message, Speak
Set args = Wscript.Arguments

For Each arg In args
  Message = Message & arg & " "
Next

if Message = "" Then
	Message=InputBox("Enter text","Speak")
End If
Set Speak = CreateObject("sapi.spvoice")
Set Speak.Voice = Speak.GetVoices.Item(1)
Speak.Rate = 0
Speak.Volume = 100
Speak.Speak Message

Go Back