
Enhance your Linux experience by giving your terminal a voice. You can easily convert text into spoken audio directly from the command line using powerful, open-source tools. This capability is not only fascinating but also incredibly useful for various tasks, from getting audio notifications to scripting spoken feedback.
The primary tool for achieving this on many Linux distributions is espeak-ng. This is a compact, open-source software speech synthesizer that supports a wide range of languages. It’s a successor to the original espeak and is known for its small size and efficient performance, making it perfect for command-line use.
Getting started with espeak-ng is straightforward. On most Debian-based systems (like Ubuntu), you can install it using your package manager. Simply open your terminal and run:
sudo apt update
sudo apt install espeak-ng
For other distributions, use their respective package managers (e.g., dnf install espeak-ng
on Fedora, pacman -S espeak-ng
on Arch).
Once installed, synthesizing speech is as simple as piping text to the command or passing it as an argument. The most basic usage is:
espeak-ng "Hello, world!"
This command will take the text “Hello, world!” and speak it using the default voice and settings.
You have significant control over how the speech is synthesized. Here are some useful options:
- -v
<voice>
: Select a specific voice. You can list available voices usingespeak-ng --voices
. Voices often correspond to languages and regional accents (e.g.,en-us
,en-gb
,fr
,es
). For instance, to use a British English voice:espeak-ng -v en-gb "Lovely day, isn't it?"
- -p
<pitch>
: Set the pitch of the voice (0-99). A higher number means a higher pitch. Example:espeak-ng -p 80 "High pitched voice."
- -s
<speed>
: Control the speaking speed in words per minute. The default is typically around 160-170. Example:espeak-ng -s 250 "Speaking quite fast now."
- -a
<amplitude>
: Adjust the amplitude (volume) (0-200). Default is 100. Example:espeak-ng -a 150 "Louder voice."
- -w
<filename.wav>
: Write the synthesized speech to a WAV audio file instead of speaking it aloud. This is useful for creating audio files from text. Example:espeak-ng "Save this to a file." -w output.wav
You can combine multiple options in a single command:
espeak-ng -v fr -p 50 -s 140 "Bonjour le monde." -w bonjour.wav
This powerful tool opens up possibilities for scripting and automation. Imagine having your scripts read out completion messages, error notifications, or even news headlines fetched from the web. Integrating espeak-ng into your shell scripts can make your command-line environment more interactive and accessible.
By mastering espeak-ng, you unlock the potential to add an auditory dimension to your Linux terminal interactions, making tasks more intuitive and providing hands-free feedback when you need it most. Experiment with the options to find the voice and settings that best suit your needs and integrate this fascinating capability into your daily workflow.
Source: https://www.linuxtechi.com/make-linux-terminal-talk-using-espeak-ng/