Using Voice Engine in VBScript


On Windows OS, you will find the COM automation object SAPI.SpVoice that brings TTS (Text-To-Speech). The following shows an example of using SAPI to speak given a sentences. By default, only English voice library is installed, you have to install languages of your choices if you want the computer speak your native languages.

1
2
3
4
5
6
7
Set voice = CreateObject("SAPI.SpVoice")
voice.Rate = 1
voice.Volume = 90
Say = InputBox("Say Something", "Say Something", "I Love you!")
If (Len(Say) > 0) Then
    voice.Speak Say
End If 
Set voice = CreateObject("SAPI.SpVoice")
voice.Rate = 1
voice.Volume = 90
Say = InputBox("Say Something", "Say Something", "I Love you!")
If (Len(Say) > 0) Then
	voice.Speak Say
End If 

The above VBScript pops up a dialog with the default sentence I love you! to say. Input your sentence and press OK, the computer will read that loud!

More properties can be found in MSDN. Try it yourself, simply save the above into a *.vbs script and let me know the gender of your computer!

You can specify the male/female voice engines in Control Panel under Speech section.

text-to-speech Using Voice Engine in VBScript beginner programming languages tricks vbscript windows windows scripting host

text-to-speech

Which gender is your computer? Comment below.

References:

1. http://msdn.microsoft.com/en-us/library/ms723602(v=vs.85).aspx

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
310 words
Last Post: Codeforces: 300A. Array
Next Post: Check A Date String If Weekend In Java

The Permanent URL is: Using Voice Engine in VBScript

3 Comments

  1. bb
  2. Mia

Leave a Reply