Skip to content

Instantly share code, notes, and snippets.

@eheikes
Created February 10, 2016 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eheikes/a51697bc63c4cabf0a3c to your computer and use it in GitHub Desktop.
Save eheikes/a51697bc63c4cabf0a3c to your computer and use it in GitHub Desktop.
Converts images & PDF files to text.
#!/bin/bash
#
# Converts images & PDF files to text.
# See http://ericheikes.com/converting-books-to-mp3-audio-text-to-speech
#
# Concatenate all the files.
cat "$@" > out.txt
# Combine words that are broken (with hyphens) across lines.
perl -0777 -i -pe 's/(\S+)-\n\s*(\S+)/$1$2/ig' out.txt
# Convert the text to speech.
text2wave out.txt -o out.wav -eval "(voice_us2_mbrola)"
# Encode as MP3.
lame -V5 out.wav out.mp3
# Clean up.
rm out.wav
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment