Are you curious to hear to what your spoken Linux computer sounds like from the command line? Are you pining away for that nostalgic, early 1980’s synthetic computer voice?
You are? Great! Because in addition to the myriad of other clever tricks Linux can perform, Linux can speak too!
Espeak is a program that converts text to synthetic speech for playback through the speakers (or headphones).
First of all, install espeak from the repository using Synaptic or the command line.
sudo apt-get install espeak espeak-gui
I would also recommend installing the GUI, espeak-gui, to become familiar with espeak.
Hear Ye! Hear Ye!
Espeak is incredibly simple. At a command line, type espeak, followed by a line of text enclosed within single quotes. (Try it without quotes, and you will hear why.)
espeak 'hello to everybody this fine day'
Linux will talk like a fast robot, and you might need to pay careful attention to understand what is being said. However, there are many options available that adjust the voice. Enter man espeak for details.
The default speaking speed of 160 words per minute is too fast to be intelligible. I find 125 to be more understandable. Use the -s option to change the voice speed.
espeak -s 125 'can you understand me now?'
How about slow and deliberate?
espeak -s 10 'can you understand me now?'
Male and Female Voices
What? You say you don’t like the 80’s robot voice? How about an 80’s robotic female voice? Use the -v option followed by the language (en for British English) plus a type.
espeak -s 125 -v en+f5 'Hey, handsome. Did you just spill soda on my designer bag?'
I think the British-like accent fits well with the designer bag part, but if she sounds a little too posh, then try a lower value, such as en+f4, to give her more “grump.”
espeak -s 125 -v en+f4 'Hey, handsome. Did you just spill soda on my designer bag?'
Or how about a robotic man?
espeak -s 125 -v en+m3 'Oh! I thought that was a trash bag.'
Too high? Try lowering his pitch with the -p option.
espeak -s 125 -v en+m3 -p 25 'I have seen roadkill with better taste'
Espeak follows the rules of input and output, so we can pipe the standard output from one program to the standard input of espeak. This is great for a program such as fortune.
fortune | espeak -s 125 -v en-uk+m5
Heh, heh. Great fun! We can also pipe text files to espeak.
cat textfile.txt | espeak -v en+f3
However, piping cat is never a best practice when espeak supports file reading itself, so use the if option instead.
espeak -v en+f3 -f textfile.txt
For long files, press Ctrl+C to quit.
To view the phoneme mnemonics, include the -x option to see what espeak sees.
fortune | espeak -s 125 -v en+m3 -x
The terminal should display what appears to be garbled text.
You can use en+f5 or en+m2 to adjust the voice types for different effects (f is female and m is male), but exact information regarding this is scarce. Trial and error seems to be the best solution.
The documentation [http://espeak.sourceforge.net/voices.html] provides information about voice files, and a number of them are installed in the
/usr/lib/x86_64-linux-gnu/espeak-data/voices directory (Linux Mint 17.1).
These are text files, not audio files, and they specify how voices should be generated. You can even create your own, so consult the espeak documentation for details.
These voices require the -v option in order to use them.
We can even combine voices (that is what the + sign was for in en+m5). But how does this work? First, choose a language, such as en or en-us (en is British English, which lends a slight accent).
espeak -s 125 -v en -p 25 'Listen to my lovely voice'
Useful variations are found in the lv directory. This is where we found the m1-m7 and f1-f5 voices. There are others, such as croak and whisper.
Append one of these to the en or en-us base. Use the + sign without spaces.
espeak -s 125 -v en-us+f2 'Listen to my lovely voice'
Some text, but different speaker. We hear a pseudo-female speaking. Try croak.
espeak -s 125 -v en+croak 'Listen to my lovely voice as I try not to cry'
Poor thing. He sounds somewhat emotional.
How about a whisper?
espeak -s 125 -v en+whisper 'Please be quiet in the sanitarium'
Shhhh! That sounded harsh. How about a female?
espeak -s 125 -v en+f5 'Please be quiet in the sanitarium'
Whoa! Did she need to broadcast that scolding? Here, we run into a limitation: We can only combine two voices. Not three. We cannot use,
espeak -s 125 -v en+f5+whisper 'Please be quiet in the sanitarium'
This only produces the default robotic voice, not a whispering female. For that, we must use whisperf (whisperf is the female whisper effect).
espeak -s 125 -v en+whisperf 'Please be quiet in the sanitarium'
Sounds like a gas pipe leak to me, but oh, well. Using the klatt3 effect adds a special robotic touch.
fortune | espeak -s 125 -v en+klatt3
The key to remember is the <language>+<type> combination.
Do you want to simply play with speech from a GUI? The espeak GUI lets you enter text and play it back.
The GUI lets you change the speed, male/female voice, but that is all. For advanced details, use the espeak command at the command line with custom options.
Yes, there are better speech synthesis programs available, but espeak provides too much fun to ignore. Many more options exists, so open the man page and documentation and experiment. Some remarks will make you chuckle since it’s not always what is said that makes a difference, but how it’s said.