Fun Mac OS X command: say

Group meetings in the Altman lab often kick off with a Unix or computing tip. These range from examples of built-in but lesser known utilities that make our lives at the command line easier, to scripting hacks, to full-fledged applications you download and install.

At the last group meeting I attended, the presenter showed us a fun little command that comes with Mac OS X, called ‘say’. This command basically does what you think it does – it says whatever comes after it. Here’s a simple example:

shwu$ say hello world

The default voice is whatever is set as the default in your system (usually a female, unless you’ve changed it), but there are many others you can use by setting the -v parameter:

shwu$ say -v Agnes "this is another woman's voice"
shwu$ say -v Bruce "this is a man's voice"

Some are especially fun, like “Bad News”, Bubbles, “Pipe Organ”, Trinoids, and Zarvox. Others are a little weird, like Albert and Whisper. And then there are ones you just shouldn’t use if you’re home alone at night – Hysterical and Deranged, for example. A more complete list can be found here.

The ‘say’ command isn’t just for amusing yourself, though the tricks you could play on people remotely are endless. You can also use it in conjunction with other commands or in scripts:

shwu$ python -c "print 'stuff'" && say done printing stuff || say you have a bug in your script

will say ‘done printing stuff’, whereas if I’d left out one of the single quotes in the python command it would have said ‘you have a bug in your script’ instead. This is great for when you start a script running and turn your attention to YouTube videos other work, but want to be notified when your script either finishes or encounters an error.

Bench scientists can get in on the fun, too. Suppose you have a complicated pipetting protocol that specifies different amounts of different things in different places. A long list can be cumbersome to print out or read, so why not ‘say’ it instead? (Actually, while you can specify a file for it to say using -f, I’m not sureĀ  how you would specify pauses if you had it read your aliquots from a text file… so you might need to create a script that wraps all the aliquot amounts in ‘say’ commands with pauses in between, and then put all that in another script… anyway, it would be pretty cool and all your lab mates would be jealous. Or maybe they’d just think you’re strange.)