Explore espeak-ng command in Linux

In this blog, we are going to discuss the text-to-speech tool in Linux which is eSpeak NG (Next Generation), and also going to set up once user login to OS that will welcome user.

So before we know how to use the eSpeak NG text-to-speech tool let’s get more knowledge about Text-to-Speech(TTS).

So, Text-to-Speech (TTS) is a technology that converts text to audio. This can be done using espeak-ng command in Linux. eSpeak is a FOOS(free open source software) speech synthesizer.


>> espeak-ng [options] [words]

Before starting make sure your linux OS has espeak-ng

>> espeak-ng --version

If not present then click here to install

espeak-ng commands

By using “man espeak-ng” command, we can view all options of espeak-ng command can learn about espeak-ng.

>> man espeak-ng

If you simply give espeak-ng and press enter it will open a STDIN for you and after giving input you have to press enter the command will read the input for you and again it will take back to the STDIN to take input from the user.

>> espeak-ng 
Working of espeak-ng

espeak-ng <text> this will speaks as it is

>> espeak-ng "welcome to espeak-ng blog"

Reading text from a file

>> espeak-ng -f textToVoice.txt
>> cat textToVoice.txt | espeak-ng

You can see working of this n below video

Taking command as input(stdin) and speaking

>> <command> | espeak-ng

take a present date and read

>> date | espeak-ng

Different Languages using espeak-ng

espeak-ng not only supports English it also supports different languages

List different languages supported

>> espeak-ng --vioces

List Femal voices

But when we run this command only shows MALE voices but not FEMAL and other extra voices too, to get all voices select one language from above list and run it shows all available voices

>> espeak-ng --voices=<language>

Changing voices

Variation In Voices


>> espeak-ng <text> -v <variation>

By default uses male voice, even we can change that

  • f1 to f5 this will gives different variations in a female voice
 >> espeak-ng hello -v f3
  • m1 to m7 this gives different variations in a male voice
>> espeak-ng hello -v m6

NOTE: If we try to use excluded this will not support

Can also use by selecting language and voice at the same time, if you select the wrong voice variation then takes default voice instead throwing error


>> espeak-ng <text> -v <language>+<variation>


>> espeak-ng "hello alexa" -v fr+f2

Here we selected the french language in a female voice variation 2

The below video shows how voice variation works

Here when we select voices between f1 to f5 female voices are coming in different voices, when we choose m1 to m7 giving male voices, except that if we choose other it’s prompting error.

Welcome User with voice using espeak-ng

Step 1: Go to the file which executes while rebooting in RedHat we have a file called “bashrc” in “/etc/” folder

>> sudo /etc/bashrc

Step 2: Write a command in this file to speak when the user start OS, added below command tp file “/etc/bashrc”

echo "Hey! `users`, Welcome to Redhat linux world" | espeak-ng -g 12ms -k30 -p 14
  • Above command echo will output espeak will take input and speak
  • `users` is a command that gives the current user in OS
  • Option “-g” gives a gap between each word
  • Option “-k” reads in high when the capital letter comes
  • Option “-p” will pitch voice level

The below video shows how this practical works

Let’s explore a bit more, now going to use different languages for the same task

Here we used the Kannada language to welcome a user

Follow all steps in the last practical only change command like this,

echo "ನಮಸ್ತೆ `users`, ಸುಸ್ಸ್ವಾಗತ ನಮ್ಮ redhat linux ಪ್ರಪಂಚಗಿ" | espeak-ng -g 10ms   -s 170 -v kn+f2
  • Above command echo will output espeak will take input and speak
  • `users` is a command that gives the current user in OS
  • Option “-g” gives a gap between each word
  • Option “-k” reads in high when a capital letter comes
  • Option “-p” will pitch voice level
  • Option “-v” takes which language and variation of language and speaks
  • Option “-s” speed the voice, by default is 160, here we increased to 170.

The below video shows how this practical works

Some other options in espeak-ng

  • Change the amplitude of the audio from 0 to 200 default value of the amplitude is 100.
For changing Amplitude>> espeak-ng -a <integer> "<Text>"  

//here integer means the value of sound amplitude
  • If we want to speak the text with order device we can use -d option for that.
>> espeak-ng -d <device>

This command uses the specified device as an audio device but, if the device is not specified then the default audio device will be used.

  • We can also create an wave file with the option -w.
>> espeak-ng -w <file name> "<Text>"

The above command will convert the text into audio and save it in the file given by us with the .wave extension so we can listen to it afterward. We can also split the audio file with the --split=<minutes> option if used with -w.

  • Not the last but, we can use -q option to quite, which will not produce any speech.
# espeak-ng -q
  • Many more you can learn by researching using “man espeak-ng” or “espeak-ng — help”

Thanks for Reading !!

Do Follow for more!!

Keep Learning !! Keep Sharing !!

You can contact me on:

LinkedIn emailme




ARTH-School of technology, BCA graduate

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Create a Coronavirus (Covid-19) App in React


Build a real-time chat with Agora.io Rtm using React TypeScript & Hooks

Seek and Destroy — The JavaScript Algorithm

5 Imperative Concepts That You Need to Use Every Day as a Programmer

Using Formik for form validations as a React developer (part 1)


JSWorld Conference 2022 Summary — 1 June 2022 — Part II

ES6 Syntax (Part 1/2)

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Vinodha kumara

Vinodha kumara

ARTH-School of technology, BCA graduate

More from Medium

How to create Static C Libraries

Investigate Logs File Using Linux | Regex

ESP32 Project 1: LED Blink

Install OPNSense and Linux on Cisco ASA