P. Kabra
Ho

How To Use The Say Command

Using the built-in MacOS say command, and customizing the voice.

MacยทMay 31, 2021

To have your computer speak to you open your terminal and enter:

say "Your Text Here"

Customizing the voice

Pass in --voice (or -v). For example:

say "Jelly" -v "Albert"

To list out all voices, use

say -v '?'
Finding voices from system preferences

There is another way to find voices.

Go to the System Preferences app. Open Accessibility > Spoken Content. You will see the System Voice dropdown.

Open that dropdown and note down the voice names you see (but don't change them!). Here are a list of voices I see:

  • Daniel
  • Kate
  • Deranged
  • ...

For example,

say "This is the deranged voice" -v "Deranged"
Testing out different voices

Go to the System Preferences app. Open Accessibility > Spoken Content. You will see the System Voice dropdown.

Scroll to the bottom and click the "Customize" button:

You can now browse through all voices, and click "Play" to test them out:

Reading from a file

Use the --input-file (-f) to specify the file to read from.

Say you have this file:

Have your computer sing with

say -f song.text

You an also use the pipe operator: cat song.text | say.

Rate

Use --rate (-r) to control the rate in words per minute of the sound.

For example,

say "I am in a rush!" -r 500
What is the default rate?

Saving as mp4 or aiff

Pass in the --output-file (-o) to pass an output file. For example:

say "Happy birthday!" -o birthday.mp3

Note that some audios may not support one of the formats.

Saving as mp3

If you try to save the output as an mp3 file (example: say "hello" -o voice.mp3), you may see this error:

Specifying ExtAudioFileRef failed: -50

To save as mp3, first save as aiff, then use the lame encoder to convert it to mp3:

say "Never gonna give you up" -o voice.aiff
lame -m m voice.aiff voice.mp3

Install lame with brew install lame.

Credits to this answer on stackoverflow.