Makzan / I share what I learned

Say — Text-to-Speech Command in OSX

The text-to-speech function in Mac OSX works in command line too.

A simple say command with a string provided:

$ say "Thank you for calling us. We are currently unavailable to take your call. Please leave us a message and we'll return your call as soon as possible."

We can control the speaking rate in words per minute:

$ say "Thank you for calling us. We are currently unavailable to take your call. Please leave us a message and we'll return your call as soon as possible." -r 180

We can export the speech audio into file:

$ say "Thank you for calling us. We are currently unavailable to take your call. Please leave us a message and we'll return your call as soon as possible." -r 180 -o ~/Desktop/voice-message-en.aiff

We can provide an input file instead of using the string parameter:

$ say -f voice-message.txt

We can specific which voice to use. And specifying “?” lists all the voice options:

$ say -v '?'

For instance, I can have a Cantonese text-to-speech with the voice “Sin-Ji”:

$ say -f voice-message.txt -v "Sin-ji" -r 70

Published on 2015-09-25. More articles like this:
- Highlighted
- Productivity

Previous <- Dealing with long words in CSS
Next -> The web as at 2006

📬 Subscribe to Makzan’s Weekly Dispatch

Want productive tips and web technologies links like this in your inbox each week? Sign up for weekly dispatch each week. No spam ever. Just useful content:

What to expect: If you wish to withdraw your consent and stop hearing from us, simply click the unsubscribe link at the bottom of every email we send or contact us at mak@makzan.net. We value and respect your personal data and privacy. To view our privacy policy, please visit our website. By submitting this form, you agree that we may process your information in accordance with these terms.