Use Microsoft Speech API (SAPI)Tag(s): WSH VBScript


The Microsoft Speech API is included with XP (or higher).

For 2000/9x, install Microsoft Speech Engine.
http://activex.microsoft.com/activex/controls/sapi/spchapi.exe

Good infos about this API can be found at
http://www.microsoft.com/technet/scriptcenter/funzone/games/sapi.mspx

Dim oVo
Set oVo = Wscript.CreateObject("SAPI.SpVoice")

If oVo Is Nothing Then
   WScript.Exho "FAILED Sapi.SpVoice creation"
Else
   oVo.Speak "Real's How To"
  
   Set oVo.Voice = oVo.GetVoices.Item(0)
   // Microsoft Sam (the default voice)
   oVo.Speak oVo.GetVoices.Item(0).GetDescription
   
   While Not Ovo.WaitUntilDone(0)
     WScript.Sleep 100
   Wend
End If

WScript.Echo "Done."

blog comments powered by Disqus