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.)

5 Responses to Fun Mac OS X command: say

  1. Neil says:

    I had never considered practical, research uses for text-to-speech. It would be a fun way to report progress in those scripts that run loops to process data. “Gene X complete…” and so on.

    FYI the Unix/Linux equivalent is festival.

    • Daniel says:

      While it would be a fun way, I am sure that after the novelty aspect wears down it would get a bit annoying. Still prefer an email or text msg to my smart phone to let me know something has finished.

      That being said, fun to use :-)

  2. Eric says:

    A while back, I wrote myself a Cocoa app that will read lines of pasted-in text out loud, pausing at ends of lines until it is given a go-ahead. It’s also possible to voice control it by reading the buttons on the screen to the computer (and activating “Voice” commands in the preferences). That way, I can paste in a protocol and sit at my bench, controlling my computer. Science of the future!

  3. Tom Roud says:

    This reminds me of the episode of “The Big Bang Theory” where Sheldon is not allowed to talk….

  4. noone says:

    say -v “cellos” This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song. This it the silly song.

Leave a reply to Daniel Cancel reply