Every Monday, we'll show you how to do something new and simple with Apple's built-in command line application. You don't need any fancy software, or a knowledge of coding to do any of these. All you need is a keyboard to type 'em out!
Whether you’re pulling a prank, or just want to have an easy text-to-speech solution for your Mac, OS X’s “say” command is definitely for you. With just one command, you can have your Mac speak any text you type, and then save that audio out as a file that can be played back at your will. Continue reading and we’ll show you how it’s done.
Basic Say Command
The basic command to make your Mac talk is fairly easy to use. Just open the Terminal and type in the following command:
say "Hello, from MacLife"
This will cause the default selected voice in OS X to spring to life and say the words that are wrapped in quotes. Pretty nifty, huh? Let’s step this up a bit, though.
Say with Different Voices
OS X comes with more than 20 voices pre-installed and ready at your disposal. Here’s a list of what’s available as of Mountain Lion:
- Bad News
- Good News
- Pipe Organ
say -v "voice name" "text to say"
Replace “voice name” with a name of the voice in the list above, and “text to say” with the text that you wish the voice to speak. For instance, if we wanted to say “Hello from MacLife” using the “Good News” voice, we’d use the following command:
say -v "Good News" "Hello from MacLife"
Interesting note: The “Droid” saying that Motorola uses in many of their Android commercials can be recreated by saying “Droid” using the “Cellos” voice.
Outputting the Audio to a File for Playback Later
Using the “say” command by itself is a good way to play a practical joke, or use it for other text-to-speech uses; but, many people will find it useful to save the voice out for later use: perhaps for use in a video, or other setting.
To do this, use the “-o” (or output) flag to specify a path and filename for the audio to be written. AIFF is the default file format, and is supported by most voices; however, other voices can use WAV or MP3 for output formats.
say -v "Cellos" "Lalalalalalalalala" -o recording.aiff
Instead of the text being spoken through the CLI interface, you’ll see a file outputted at the path you specified. There are many uses for this, so feel free to experiment.
Cory Bohon is a freelance technology writer, indie Mac and iOS developer, and amateur photographer. Follow this article's author on Twitter.