macOS includes a highly advanced, built-in text-to-speech engine that powers accessibility features like VoiceOver. However, you don’t need to navigate through System Settings to use it. The macOS Terminal provides direct access to this engine via the incredibly fun and useful say command.
The say command takes any text you provide and reads it aloud using the Mac’s synthesised voices. While it is certainly entertaining, it also has practical applications for scripting, accessibility, and audio generation.
Basic Text-to-Speech
The simplest way to use the command is to type say followed by the phrase you want the Mac to speak.
say "Hello, your download has finished."
Press Enter, and your Mac will speak the phrase using the default system voice.
Reading the Contents of a File
If you want your Mac to read a long document to you while you rest your eyes, you can pass a text file to the say command using the -f flag.
say -f /Users/John/Documents/report.txt
The command will read the entire file sequentially. You can press Ctrl+C in the terminal at any time to stop the playback.
Changing the Voice
macOS comes pre-installed with dozens of different voices with various accents and characteristics. To see a complete list of all available voices on your system, run:
say -v ?
This will output a list of names (e.g., Alex, Samantha, Daniel, Karen). To use a specific voice, use the -v flag followed by the voice’s name:
say -v "Daniel" "Hello, I am speaking with a British accent."
Note: If the voice name consists of multiple words, ensure you wrap it in quotes.
Saving Speech to an Audio File
One of the most practical uses of the say command is generating audio files. Instead of speaking the text through the speakers, you can instruct say to save the audio directly to a file using the -o flag.
say -v "Samantha" "Please leave a message after the beep." -o voicemail.aiff
By default, the audio is saved in the uncompressed AIFF format, which is standard for Apple audio software. You can easily convert this to an MP3 or AAC file later using the Music app or a command-line tool like ffmpeg. This is highly useful for generating placeholder voiceovers for videos, podcast intros, or phone system greetings.
Integrating say into Shell Scripts
The true power of the say command lies in its ability to provide audible feedback from shell scripts. If you have a script that takes a long time to run (such as compiling code or running a backup), you do not need to stare at the screen waiting for it to finish. You can append the say command to notify you when it is done.
./run_massive_backup.sh ; say "Backup complete."
You can even use it to alert you to failures by checking the exit status of a command:
make build || say "Warning, the build has failed."
With just a few keystrokes, the say command transforms your Mac into an audible assistant, making your terminal workflows both more productive and considerably more interactive.