Batch, VBS, and scripts in general are incredibly useful for repetitive tasks. Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago. Some scripts may complete nearly instantly when you only have a little to do and could take many minutes when you have a lot to do and short of paying close attention to the progress of the script (about as interesting as reading pi), you probably won't know when the script actually completes.
To solve this problem, at least for myself, I wrote the following VBS script that verbally tells you when it's done. This script, when saved to a .vbs file, should execute much like any other command line command. Thus, it can be easily integrated into any batch script (really any scripting language that can execute a command line command) and with a little tweaking, incorporated into other VBS scripts.
On Error Resume Next
Dim Speaker 'Becomes the object that is used to speak.
Dim VoiceList, Voice 'Used in the loop to list the available voices
Dim Words 'Words to speak
Dim Speed 'Speed to speak, range is -10 (slow) to 10 (fast)
'Create the speaker object
Set Speaker = CreateObject("SAPI.SpVoice")
'Get the words to speak
Words = WScript.Arguments.Item(0)
If Err.Number = 9 Then 'No command line parameters entered, including words to speak. Popup a usage dialog
Words="Nothing to say!" & vbCrLf & vbcrlf & "Syntax:" & vbCrLf & "SPEAK ""hello world"" [slow|normal|fast|-10 to 10]"
If Lcase(WScript.Arguments.Item(0)) = "list" Then 'list the voices available - most systems only have the default Microsoft Ana.
For each Voice in Speaker.GetVoices
VoiceList = VoiceList & Voice.GetDescription & vbcrlf
Else 'speak the word or words in quotes specified as the first parameter
Select Case LCASE(WScript.Arguments.Item(1)) 'If a second parameter is specified, it's the speed of the voice. Talk slow or Talk fast.
Speed = -5 'slower
speed = 5 'faster
case else 'either set the speech speed to normal OR use an absolute value (-10 to 10 - very slow to very fast)
If IsNumeric(LCASE(WScript.Arguments.Item(1))) = True Then 'If the second parameter is a number then
If CInt(WScript.Arguments.Item(1)) > -11 And CInt(LCASE(WScript.Arguments.Item(1))) < 11 Then 'checking that the number is between -10 and 10
Speed = WScript.Arguments.Item(1)
Else 'an invalid number was entered, using the standard speed.
Speed = 0
Else 'speed not specified, defaulting to normal
Speed = 0
Speaker.Rate = speed 'set the speech speed for the speaker
Speaker.Speak Words 'say the words as obtained earlier.
Save the above code as "speak.vbs" somewhere that's in your path environment variable.
To test, create a small batch file that does nothing more than provide a directory listing:
dir c: /s /b
speak "Directory listing complete"
And then execute the batch file.
(Just make sure your sound is not muted and your speakers are on!)
I create two folders on every system I setup - C:\Windows\Utils and C:\Windows\Scripts. I then add these folders to my system's path statement. This allows me to store all my scripts and utilities in appropriate places, separate from Windows files, and access them easily regardless of where my script needs to execute. Otherwise, you would constantly need to reference the full path of the scripts you create or store them in places like C:\Windows\System32 - a less than ideal place.
If you prefer to use vbs scripts yourself the "magic line" (not specifically in the above script) with no alterations is:
CreateObject("SAPI.SpVoice").Speak "Hello World"
And if you're familiar with using objects in VBS scripts, you'll likely easily decode my script and be able to a adapt it to whatever project you like.
It's also worth noting that there are many variants of VB and the syntax will likely be the same or similar if you want to incorporate a verbal alert in a macro for an Office file like an Excel spreadsheet or Word document - VBA and VBS are very similar.
One final note - if the words you're using aren't pronounced properly, consider spelling phonetically.