espeak is a compact command-line speech synthesizer.
sudo dnf install espeak # or apt-get install espeak-ng (the actively maintained fork)
espeak "Hello, I am a computer"
espeak -f notes.txt # read a text file aloud
espeak -s 140 -v en+f4 "a slower, different voice" # -s = words per minute, -v = voice
espeak -w out.wav "save to a file instead of speaking"
Data file locations vary by distribution/package (for example under /usr/share/espeak-data or /usr/lib/<arch>/espeak-data); espeak --voices lists what's installed.
Fun: fortune read aloud¶
fortune -s | tee >(espeak -s 140 -ven+f4)
See fortune.
Convert other formats to text first¶
espeak only reads plain text. Extract text from other formats before piping it in:
| Format | Tool |
|---|---|
.doc |
antiword file.doc |
.pdf |
pdftotext file.pdf - (poppler-utils) — see the pdf skill for programmatic PDF handling |
.odt |
odt2txt file.odt |
| scanned image/PDF | tesseract (OCR) |
pdftotext report.pdf - | espeak -s 150
espeak-ng is the actively maintained continuation of the original project and is the better choice on current systems where available.