I have an always-on Mac mini that sits in the corner of my office. It toils away running staging servers for media, web development, and home automation. It also runs a lot of scheduled scripts.
I’m happy to have most of those scripts just run silently. Important notifications and errors get sent to my laptop and mobile devices via the Pushbullet API. Some fall in between those levels of severity, though. I have scheduling systems, such as the one that lets me schedule a generate and deploy of my Jekyll blog based on future dates found in posts1. I like to have these quietly announce themselves (with a little bit of status notification), just so I know they’re running if I’m in the office.
I love the
say command in OS X for this purpose. For scripting purposes, it’s as simple as
say "what you're doing" in a shell or AppleScript. You can customize the script to say something appropriate, and even pass variables to it to make it dynamic. I discovered the
-v flag for
say a couple of years ago, and it doubles its usefulness in this application.
You can use
-v NAME to change the voice of the speech synthesizer to any of the available system voices. This lets me give a different voice to each context, and use a different timbre for different status reports.
You can see all the available voices using
say -v ?. Then, in your shell command, just use
say -v Zarvox "[text to speak]" to switch. There’s also a useful
-r flag, which changes the rate of speech (by words-per-minute). I find that
-r 250 provides more fluid speech than the default for short sentences.
Side note: I’ve mentioned it before, but
say is pretty smart about things like roman numerals. A few quirks, but try
say "Mac OS X" or
say "Superbowl XXVII".
There are a bunch of new voices in the recent versions of OS X, mostly an assortment of localized voices geared toward languages other than English. Here’s the full list with localities, and asterisks to indicate recent additions.
While exploring the new voices, I made a quick shell script to test them all at once. You can run it alone for default settings, or pass it a test string and/or a rate setting, e.g.
play_all_voices.sh "this is my test string" 250. And here’s the audio output, in case you don’t want to bother:
By the way, Apple recently (10.10.3) broke the
atcommand I’ve always used for this. I’ll post soon about a solution using Automator, osascript, iCloud, and Calendars.↩
Ryan Irelan has produced a series of shell trick videos based on BrettTerpstra.com posts. Readers can get 10% off using the coupon code