Say you, say me, say task complete

Changing subjects for a bit from ADO.NET Data Services to an easy way to impress your friends...

If you've never heard about this, you're in for a treat. The Microsoft Speech API (SAPI) is very, very easy to automate, and can come in handy when you want to call attention to something.

For example, I often find that I run command-line scripts or programs that take a long time to complete. I have a script on my path, speak.js, which simply says 'task complete'. I can go ahead and type the command into the console (so it goes into the buffer and runs when whatever is going on finishes), and then go distract myself with something else.

And, as you can see, the script is very, very simple.

// This script uses the Speech API to speak to the user.
// Useful for batch scripts or typing on the command-line to compensate for
// short attention spans (or multitasking).
// Usage:
// speak.js -- says 'Task complete'
// speak.js /say:"Hello, world!" -- says 'Hello, world!'

// Uses the Speech API to speak to the user.
function Say(text)
var voice = new ActiveXObject("SAPI.SpVoice");
try {
catch (e) {
// See for error codes.
// SPERR_DEVICE_BUSY 0x80045006 -2147201018
if (e.number == -2147201018) {
WScript.Echo("The wave device is busy.");
Happens sometimes over Terminal Services.");

var text = WScript.Arguments.Named.Item("say");
if (text == null) {
text = "Task complete";

One more tool for your toolkit - enjoy!


This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at