May 162008
 

This post on Lifehacker made me slap my head. I had recently spent a while trying to figure out how to automate having the Mac “read” a book–use its excellent built-in Text-To-Speech system to convert an eBook into an audiobook. The Mac voices aren’t going to replace Derek Jacobi or Bob Inglis for nuanced and powerful reading of great books, but they will get the job done when there’s no other option for creating an audiobook short of reading it aloud yourself.

My first attempt at automatic eBook-to-audiobook translation was to use Automator. I created serveral Workflows, one per speaking voice, with the following Actions:

1. Open Finder Item (the eBook in
text format) with TextEdit.

2. Get Contents of TextEdit. Send
output to:

3. Text To Audio File. Save as
“vickispeak” (for voice “Vicki”)
on the Desktop.

This works quite well, but is a little slow. To run it, I right-click on the input text file in a Finder window, then select Automator from the pop-up menu, and the desired voice’s Workflow from the Automator submenu. It creates an AIFF audio file called “vickispeak” on the Desktop. It does exactly the same thing as the single ‘say’ command, which can be run with much less theatrics from Terminal (type this in all on one line):

say -v Vicki -o ~/Desktop/vickispeak
-f ~/Desktop/ebook.txt

The options to ‘say’ are:

  • -v voiceName
    One of Agnes, Kathy, Princess, Vicki, Victoria, Bruce, Fred, Junior, Ralph, Albert, or one of the many “novelty” voices; there are supposed to be more and better voice options under OS X 10.5. If not specified, the current “System Voice” is used; this is set under the “Text To Speech” tab under “Speech” System Preferences.
  • -o outputSoundFileName
    If not specified, the input text is spoken aloud.
  • -f inputTextFileName
    If not specified, the text to be spoken can be listed as arguments on the command line.

Further details on ‘say’s arguments can be found by typing this in Terminal:

man say

But that’s not the end of things. You can import the resulting (potentially huge) AIFF file into iTunes and convert it to MP3 format (and use very low-quality conversion options to save disk space). You can then copy the (much smaller) MP3 file to your iPod or other portable music player, and play your new audiobook back while commuting, etc.

And you can add some useful commands at the top of your eBook text file that will instruct the Mac books to speak more quickly or at a different pace. According to the Apple Developer’s website, these commands are deprecated, so they may not work under OS X 10.5. The handiest one I’ve found is to add this single line at the very top of the eBook text file:

[[rate +40]]

I’ve found that when using the Vicki voice, “+40” makes her speak much faster, but she’s still comprehensible. This is completely a matter of taste. To make the rate of speaking slower, use a negative number instead of a positive one. More details on the speech commands you can embed in your text files can be found at this Apple Developer webpage.

Now, of course, all of this presumes that you’ve got an eBook in a raw text file or in some format that can be converted to text. You can find these kinds of books at websites like Project Gutenburg that sponsor copyright-free and otherwise non-restricted texts. A handy list of these sites is on the OLPC News Forum.

Note that if the eBook you want to convert into an audiobook is only in PDF format and not in raw text, using the Automator Workflow instead of the ‘say’ command may make things easier, as Automator has an “Extract Text From PDF” Action built-in, which makes dealing with PDF files relatively easy. More details can be found in this Apple Support discussion.

Note that there are commercial / shareware / freeware applications which will help you create audiobooks more easily and with greater control than these DIY methods:

  • GhostReader is an audiobook recording suite; it even includes more voices.
  • Audiobook Builder will help you organize your audiobook recordings into chapters, and convert your sound files into audiobook formats that iPods and some other MP3 players support bookmarking and other enhanced playback capabilities for.
  • Charles Kelly’s Text-To-Speech to MP3 free application combines all of the steps outlined above into a single step.
  • TypeIt ReadIt is a shareware app that can convert text files to MP3 audio files, and can help visually challenged readers with other tasks.
  • Wizzard / AT&T Natural Voices Text-To-Speech SDK helps you create your own multiplatform applications.
  • iSpeak-it converts many document types, including web pages and RSS feeds, to spoken audio files.
  • MaxPod converts web pages to spoken audio files for use on your iPod.
  • Narrator helps you script your audiobooks by changing the speaking voice, pitch, and other qualities.
 Posted by at 8:47 PM