Terminal Icon

Save Text To Spoken Audio File (Text To Speech) via Terminal

Have you ever needed (or wanted) to create a spoken word audio file on your Mac? You can use the Mac’s “Say” command via Terminal to create an audio file with your text.

Example of Terminals Ability to Speak Text

  1. Open Terminal (Applications / Utilities / Terminal.app)
  2. Type (or Copy) the following and press Enter/Return
say "A quote by Ralph Waldo Emerson - The greatest glory in living lies not in never falling, but in rising every time we fall."

Save Text As Audio File

Now let’s save the spoken text to an audio file. For this example we will use the same quote as above but save it to a file called “spoken_text.aiff” on your desktop.

  1. Open Terminal (Applications / Utilities / Terminal.app)
  2. Change your working directory to your Desktop
  3. Type (or Copy) The following and press Enter/Return
cd ~/Desktop/
  1. Type (or Copy) the following and press Enter/Return
say -v Alex -o "spoken_text.aiff" "A quote by Ralph Waldo Emerson - The greatest glory in living lies not in never falling, but in rising every time we fall."

Save Text As Audio File Read In From a Text File

If you have a lot of text you wish to save into an audio file you can have Terminal read in your text to be spoken from a standard text file.

  1. Open Text Edit (Applications / TextEdit.app)
  2. Type (or Copy) the following into your text file
A quote by Ralph Waldo Emerson - The greatest glory in living lies not in never falling, but in rising every time we fall.
  1. Save the file to your Desktop with the name “text_to_be_spoken.txt”

Now that you have a file named “text_to_be_spoken.txt” on your desktop containing the quote above you can have Terminal create the audio file from the text file.

  1. Open Terminal (Applications / Utilities / Terminal.app)
  2. Change your working directory to your Desktop
  3. Type (or Copy) The following and press Enter/Return
cd ~/Desktop/
  1. Type (or Copy) the following and press Enter/Return
say -v Alex -o ~/Desktop/spoken_text.aiff -f ~/Desktop/text_to_be_spoken.txt

Wrapping Up

You can change the voice used in audio file by substituting the name “Alex” with any other System Voice (example: “Samantha”) you have available on your system.

To see what System Voices you have available (or download additional voices) open System Preferences > Accessibility > Speech.

For help with Terminals Say commands

  1. Open Terminal (Applications / Utilities / Terminal.app)
  2. Type (or Copy) the following and press Enter/Return
man say