DEV Community

Cover image for VBScript - Text to Speech/Play Sound
Dan Wheeler
Dan Wheeler

Posted on

VBScript - Text to Speech/Play Sound

Create a .vbs file with the following code, and it will play a sound and also say something out loud of your choosing... neat huh?

Set oV = CreateObject("SAPI.SpVoice")
Set oFS = CreateObject("SAPI.SpFileStream")
oFS.Open "C:\Windows\Media\tada.wav"
oV.SpeakStream oFS
oFS.Close
oV.Speak "Hello World!"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)