Use OSX say Command To Convert Old Books from Gutenberg
It really is so nice to have access to so many books and at only the cost of paying an internet connection and the occasional donation. For some time now I’ve been frequenting gutenberg.org and partaking of their book selection.
There are a few ways to go about reading these wonderful old texts. The reader can print, read digitally, read aloud with friends or family, and another way is to make the computer read it to you. The latter is the method I want to go into here.
This method is for people using OSX who can operate a terminal. We will locate the book we want, copy the text, paste it into a file, and make the
say command output it to audio.
For example you could choose a book like “The Adventures of Sherlock Holmes” by Arthur Conan Doyle. I recommend selecting the plain text version for our purposes. Once you have found the book you want and selected the format please select the text you want with
It may be necessary to repeat this method for each chapter.
Now that we have selected our book and we’re ready to start going with the more technical part of the method we’ll first locate a place to put these files.
mkdir sherlock-holmes cd sherlock-holmes
If we’ve copied just one chapter, like chapter #1 “A Scandal in Bohemia”, to the clipboard we can output that straight to a file by using
pbpaste into output redirection with
>. Here’s how.
pbpaste > chapter1.txt
That will send what you have copied into a new file called
chapter1.txt. To see if that has worked correctly lets confirm what is in that file using
cat chapter1.txt # v v v v v v v v # the file contents should match what you copied
Assuming that has worked and your text has gotten correctly into the file we can now select which voices we like the best from OSX’s collection. If you haven’t already you can play, select, and remove different voices from OSX’s preferences panel under “Dictation & Speech.”
Whatever voice you like to use will be available via command line as well. You may confirm by listing the voices.
On a side note most of the high quality English-speaking voices are female. The people who made this feature spent a lot of time making a mockery of out of most of the male voices.
We’ve copied the text and created a file. We can proceed to the next step of converting it to audio. It’s quite easy!
say --voice=Susan --input-file=chapter1.txt --output-file=chapter1.ogg
Alternatively that can get shortened down to a less obvious form using shorter flags.
say -v Susan -f chapter1.txt -o chapter1.ogg
Notice that the output format I used was
.ogg for the Ogg Vorbis format. You might want to experiment with other types if you can’t use Oggs. Try mp3, aiff, wav, or flac.
For further information about how to use
say in OSX the manual is available.
Tip: Try the
--progress flag to see it working!
If you want to learn more about the many options it has available you can read through the manual.
It does help a lot to have this feature available in OSX, especially when I’m on the road, doing chores, or too tired to parse text. The
say output does have rough spots with pronunciation. After being spoiled by some great audio-book readers I also found myself discovering a new appreciation for the value that book readers, or voice actors, are bringing to the readings. They can bring their human passion to help emphasize and dramatize certain parts of the books.
I hope you too can enjoy discovering the old stories and lost wisdom published on Gutenberg.