Convert a Text File into Spoken Audio via Command Line

Jun 28, 2011 - 14 Comments

terminal 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.

Enjoy this tip? Subscribe to the OSXDaily newsletter to get more of our great Apple tips, tricks, and important news delivered to your inbox! Enter your email address below:

Related articles:

Posted by: William Pearson in Mac OS X, Tips & Tricks

14 Comments

» Comments RSS Feed

  1. Peter says:

    Wish I had this in college :p

  2. Rob says:

    The conversion of a .rtf to .m4a works; but the only audio being output is the file name. For example the test file “test.rtf” – the file is converted but the .m4a file name is what is read to me. Not the text in the file. What am I don’t wrong?

  3. TY says:

    Playing w/ the Convert a Text File into Spoken Audio function but the command only creates an audio file that speaks the name of the original file? A step must be missing or I am doing something wrong. Please help. This would be a HUGE asset!

  4. mike says:

    I just open text files, web pages select all or the text i want then go to services menu and select add to itunes as a spoken track.

  5. TY says:

    Never mind guys. I found a much better source that take all the effort out of this. No Terminal. No Commands. Just point and click:

    http://automator.us/leopard/examples/ex07/index.html

    Thanks Rob.

  6. Sven says:

    Worked for me with “say -o audio.m4a -f text.txt”

    What is this Services menu and why do I not have it?

  7. mike says:

    all os x users have services menu. In all apps under the applications name in the menubar, same menu selection you get to the about this application or preferences for the app. hope this helps.

  8. Ty says:

    Seriously, don’t even bother with Terminal and command line stuff. Just use Automator. They have a prebuilt workflow that does all the work for you to include putting your highlighted text/copied to the clipboard right into an iTunes file. No fuss, no key commands. Just a sweet one click solution.

    http://automator.us/leopard/examples/ex07/index.html

  9. [...] showed you how to convert text to spoken audio files via the command line but some people ran into trouble with that method. It turns out I completely over-engineered how to [...]

  10. mike says:

    better to over-engineered than under-engineere

  11. [...] forget that you can also convert a text file to a spoken audio file, this can be achieved through the command line or by using the simpler “Add to iTunes as [...]

Leave a Reply

 

Shop for Apple & Mac Deals on Amazon.com

Subscribe to OSXDaily

Subscribe to RSS Subscribe to Twitter Feed Follow on Facebook Subscribe to eMail Updates