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 {
voice.Speak(text);
}
catch (e) {
// See https://msdn2.microsoft.com/en-us/library/ms717306.aspx for error codes.
// SPERR_DEVICE_BUSY 0x80045006 -2147201018
if (e.number == -2147201018) {
WScript.Echo("The wave device is busy.");
WScript.Echo(" Happens sometimes over Terminal Services.");
}
}
}
var text = WScript.Arguments.Named.Item("say");
if (text == null) {
text = "Task complete";
}
Say(text);
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 https://www.microsoft.com/info/cpyright.htm.
Comments
Anonymous
January 31, 2008
Changing subjects for a bit from ADO.NET Data Services to an easy way to impress your friends... If you'veAnonymous
January 31, 2008
Cool...heard using Anna on XP :)Anonymous
January 31, 2008
You can make your PowerShell scripts fun by adding speech. Wouldn't it be cool if your script finishedAnonymous
April 15, 2008
I was just reading How to speed up Windows Vista on tech.msn.com, written by Scott Dunn of PC World,