say(1) is a command line utility which uses OS X’s speech synthesis engine to transform text into sound. I recently played around with it a bit and found some nifty things it can do.
I wanted a quick way to convert text to an audio file for a short chapter of a book I am listening to on my bike. Unfortunately the book is written in German and my system is set to US English. Therefore
say uses OS X’s default voice, Alex.
say use a foreign tongue, simply use the
-v operator. But first you must download some foreign voice under System Preferences → Dictation & Speech → Text to Speech → System Voice → Customize…. Anna is a good German voice. Let
say use a downloaded voice:
say -v Anna "Nein."
say can also use plain text files to read from with
say -v Anna -f ~/Desktop/"Some Markdown.md"
say can write its output to a file with
say -v Anna -f ~/Desktop/"Some Markdown.md" -o ~/Desktop/article.aiff
-o allows you to specify many file formats too. Generally it’s easiest to specify the desired extension, e.g. m4a, aiff, etc, but you can also give
say many more options such as:
say -v Anna -f ~/Desktop/"Some Markdown.md" -f ~/Desktop/article.m4a --bit-rate=?
This will give you a list of possible bit rates. Check
man say for more.