How to Convert Text Document to Speech on Ubuntu Using eSpeak

by SathiyaMoorthy on March 8, 2010

Photo Courtesy: db*photography

Photo Courtesy: db*photography

Ubuntu espeak is a speech synthesizer for English (and several other languages) which will convert text to speech.

You can straight away execute espeak command on your Ubuntu machine without any installation or configuration.

In this article, let us review 8 examples of espeak command.

espeak Example 1: Speak the words specified in command line

This is the default usage.

# espeak --stdout 'words to speak' | aplay

Note: The above may also display the following message: “Playing WAVE ‘stdin’ : Signed 16 bit Little Endian, Rate 22050 Hz, Mono”

espeak Example 2: Speak the words specified in stdin

This will take the words interactively from the standard input and convert it to speech.

# espeak --stdout | aplay

espeak Example 3: Speak your document

This will convert the text from the mydocument.txt to speech.

# espeak --stdout -t mydocument.txt | aplay

espeak Example 4: Generate voice file from text document

Convert your text file to an audio file as shown below.

# espeak -t mydocument.txt -w myaudio.wav

Customizing espeak

If you find the default speech synthesizing is not good, you can try to customize it as explained below.

espeak Example 5: List all available voice languages

# espeak --voices
Pty Language Age/Gender VoiceName       File        Other Langs
 5  af             M  afrikaans         af
 5  bs             M  bosnian           bs
 5  ca             M  catalan           ca
 5  cs             M  czech             cs
 5  cy             M  welsh-test        cy
 5  de             M  german            de
 5  el             M  greek             el
 5  en             M  default           default
 5  en-sc          M  en-scottish       en/en-sc    (en 4)
.......

espeak Example 6: Choose a different voice language

The following will use “en-uk” – British english to translate the text to speech.

# espeak -v en-uk --stdout 'reading tips & tricks in TGS' | aplay

espeak Example 7: Increase or Decrease the number of spoken words per minute.

The default is 160 words per minute. You can reduce it using option -s as shown below.

# espeak -s 140 -f mydocument.txt | aplay

espeak Example 8: List the available espeak voices in specific language

The following example will display all possible english language variation that you can use for your text to speech conversion.

# espeak --voice=en
Pty Language Age/Gender VoiceName       File        Other Langs
 2  en-uk          M  english           en/en       (en 2)
 3  en-uk          M  english-mb-en1    mb/mb-en1   (en 2)
 2  en-us          M  english-us        en/en-us    (en-r 5)(en 3)
 5  en-sc          M  en-scottish       en/en-sc    (en 4)
 5  en             M  default           default
.....

Linux Sysadmin Course Linux provides several powerful administrative tools and utilities which will help you to manage your systems effectively. If you don’t know what these tools are and how to use them, you could be spending lot of time trying to perform even the basic administrative tasks. The focus of this course is to help you understand system administration tools, which will help you to become an effective Linux system administrator.
Get the Linux Sysadmin Course Now!

If you enjoyed this article, you might also like..

  1. 50 Linux Sysadmin Tutorials
  2. 50 Most Frequently Used Linux Commands (With Examples)
  3. Top 25 Best Linux Performance Monitoring and Debugging Tools
  4. Mommy, I found it! – 15 Practical Linux Find Command Examples
  5. Linux 101 Hacks 2nd Edition eBook Linux 101 Hacks Book

Bash 101 Hacks Book Sed and Awk 101 Hacks Book Nagios Core 3 Book Vim 101 Hacks Book

{ 11 comments… read them below or add one }

1 Ganesh March 8, 2010 at 4:38 am

nice features. thanks to bring her..

2 Seif Abaza March 8, 2010 at 5:48 am

it’s Good Way to leaning how to speaking any language :D

3 Chris F.A. Johnson March 8, 2010 at 12:36 pm

How does “Ubuntu espeak” differ from the version that is available for all Linux distros (as well as Windows)?

4 Paul March 8, 2010 at 1:33 pm

First, I must confess that I have gleaned much from the daily gems from this group. I appreciate your efforts greatly. Second, not meaning to be critical at all, but to clarify,

espeak Example 3: Speak your document

This will convert the text from the mydocument.txt to speech.

# espeak –stdout -t mydocument.txt | aplay

should the “-t” not in fact be -f (file)?

5 Soumya Mandi June 10, 2010 at 2:42 pm

Amazing .. I don’t know how I missed this ! Thanks a lot :)

6 vichithra October 12, 2010 at 11:56 pm

this is an excellent tutorial. thanks a lot

7 vamsi March 22, 2011 at 8:29 pm

hey i am unable to convert text to speech can any one help me. i created a txt file on my desktop and i changed my path in terminal to desktop then i use this command
#espeak mydocument.txt -w myaudio.wav
it show in desktop my audio.wav but when i play it i am unable to listen what the file my document.txt contain

8 bv August 7, 2011 at 3:27 pm

#espeak -f mydocument.txt -w myaudio.wav

9 Nicholas August 25, 2011 at 10:47 am

while reading my text file, for every statements that ends with semicolon, i want it to stop for 10 seconds, and continue with the next line.

10 Edward López October 10, 2013 at 3:31 pm

Priceless information. Very nice. really helped. thnx.

11 kuman March 3, 2014 at 1:50 am

Great information…. very useful…..

Leave a Comment

Previous post:

Next post: