Convert a Text File into Spoken Audio via Command Line
Using Mac OS X Text to Speech tools, we can convert any .RTF or .TXT file into a spoken audio file which can then be transferred to your iPod or iPhone for later listening.
Update: There is an easier way to do this using the Services menu, you may want to try that first unless you prefer the command line.
The command format is as follows:
say -o output.m4a -f /path/to/file.txt
The default output will be to the Terminals present working directory (usually your Home), but you can specify it to go elsewhere if you want. Here’s an example, with the output going to the desktop and the input file coming from a documents folder:
say -o ~/Desktop/textaudio.m4a -f ~/Documents/HugeDocumentNobodyWantsToRead.txt
If you want to use a text file that is buried deep somewhere on your Mac, remember you can drag and drop the icon into the Terminal to display it’s full path.
The audio file will be in M4A format and be read as whatever your current default text-to-speech voice is. If you’d rather have an mp3 file, just use iTunes to convert m4a to mp3, and you can always change the voice with the -v flag or by setting the default to something different.
Update: If you are having any problems, try using a plain text .txt file as the input document.