espeak : Text to speech synthesizer in Ubuntu/Linux

Espeal title image

espeak is linux text to speech synthesizer utility in english (and several other languages). It convert text to speech from command line or the file. Espeak also can be tuned with various configurable parameters like language of voice, pitch of voice, words per minute rate etc.

In this article we explore espeak command. Later we shall finally write sample startup script that will greet you based on the time of the day.

You May Like

Installing espeak

On debian based system (Ubuntu)

sudo apt-get update
sudo apt-get install espeak

For fedora based system

sudo dnf install espeak

Using espeak

Espeak : speak words specified in command line

espeak "I love Linux"

To show summary of options

espeak -h 
espeak summary image

--voices : list out available voices. Use -v <voice> option to use particular voice

#speak hindi dilect
espeak -v hi "नमस्ते"
espeak dilect image

-f [fileName] :To read out file

espeak -f /home/savan/readFromFile.txt

Increase or decrease number of spoken words per minute. Default is 160.

espeak -f story.txt -s 140

To write output into audio format rather than to speaker

espeak -v hi "नमस्ते" -w /tmp/file.wav

You can play this file with audio player like vlc

 vlc /tmp/file.wav
espeak audio file example image

Writing startup greetings script

Let’s use espeak command to write script that will greet you based on time of the day every time you login your computer.

Copy the contents below to file named in your home folder

/home/savan/ file content:

h=`date +%H`

if [ $h -lt 12 ]; then
  espeak -v en "Good morning Savan."
elif [ $h -lt 18 ]; then
  espeak -v en "Good afternoon Savan."
 espeak -v en "Good Evening Savan."

Make this file executable

chmod 777 /home/savan/greetings.txt

Open searchbox and open "Startup Applications"

espeak startup application image

Click "Add" button

Add following details

Name : Login Greeting

Command : sh /home/savan/

Comment: Greets on login

espeak startup application image

Save it! Next time upon login, you will hear greetings based on time of the day. You can customize it more according to your preference!


So that was it in this short article. Linux OS is fun to play with. Comment your issues or suggestions etc in section below. These commands on linux helps you to customize the desktop environment accroding to your preference. If you liked this article, share with your friends. Subscribe to blog posts. Comment down in section below.
That's all for now. Do leave suggestions, comments or questions in the comment section below.