Espeak
Espeak is a free and open source text to speech utility that can be used to convert text to speech in many different languages. It comes with a command line utility as well as a library that can be used in your own app. Most of the voices available in Espeak sound robotic but it is one of the most comprehensive and widely used open source text to speech available today. It supports converting text to speech in more than 40 different languages and you can also save speech to audio files in WAV file format. It also comes with built-in support for converting text into phonemes so that you can use them in other apps, including other text to speech engines.
You can install Epseak in Ubuntu by using the command mentioned below:
You can download Espeak in other Linux distributions from the package manager. More download options are available here.
To convert a piece of text to speech using Espeak, use a command in the following format:
You can replace the content in quotes with your own desired string. To synthesize entire contents of a file to speech, run a command in the following format:
To change language and voice style, run a command in the following format:
You can replace “en-gb” with your desired voice code. A list of all available voices and their codes can be found by running the following command:
To save synthesized speech to a WAV file, run a command in the following format:
You can replace “output.wav” with any other name of your choice.
To know more about other command line options available for Espeak, use the following two commands:
$ man espeak
Festival
Festival is another free and open source text to speech engine that works similar to Espeak. It provides a command line utility to convert text to speech as well as an API that you can integrate in your own app. Other main features of Festival include support for converting text to speech in multiple languages, built-in interactive interpreter, a client-server API to access it remotely, and its own scripting engine.
You can install Festival in Ubuntu by using the command mentioned below:
You can download Festival in other Linux distributions from the package manager. More download options are available here. An online demo showing the capabilities of the Festival is available here.
To convert a string to speech, use a command in the following format:
You can replace “Test” with any other string of your choice. To convert contents of a text file to speech using Festival, run a command in the following format:
You can change voice language by running the command below:
You can replace “americalenglish” with other languages supported by the Festival. To get a list of all supported languages, run the command below:
To run Festival in interactive mode, use the following command:
You can learn more about interactive mode specific commands from here.
To know more about other command line options available for Festival, run the following two commands:
$ man festival
Pico Text to Speech Engine
Pico is a free and open source text to speech engine that is included by default in Android Open Source Project (AOSP). The voice styles included in Pico TTS sound less robotic than Espeak and Festival. Currently, Pico TTS supports speech synthesis in English, Italian, German, French, and Spanish languages.
You can install Pico TTS in Ubuntu by using the command mentioned below:
You can download Pico TTS in other Linux distributions from the package manager. Alternatively, you can compile it from source code available here.
Pico TTS doesn’t have a command to directly speak out synthesized speech from stdout. However, it can read contents of a text file or a string and can save synthesized speech into a WAV file which can then be played in any audio player.
To convert a string to speech and save output to a WAV file, run a command in the following format:
You can replace “Test” with your own desired string. To change language, replace “en-EN” with codes for other supported languages. Pico TTS supports the following language codes: en-US, it-IT, es-ES, en-GB, de-DE, and fr-FR.
To read contents of a file and convert it to speech, run a command in following format:
You can replace “test.txt” with any other file name.
To know more about Pico TTS command line options, run the following two commands:
$ man pico2wave
gTTS
gTTS is a command line application and library based on Google Translate’s text to speech engine. Based on Python, it can be used to develop other TTS apps or you can use it as a command line utility to synthesize speech from text. It features much more natural sounding voices than other utilities mentioned in this article, as Google Translate’s text to speech engine is updated quite regularly with new algorithms, natural sounding voices and features.
You can install gTTS in Ubuntu by using the command mentioned below:
You can download gTTS in other Linux distributions from the package manager. Alternatively, you can install it from the pip package manager.
To convert a string to speech, run a command in the following format:
You can replace ‘test’ with any string. The synthesized speech is saved in the “test.mp3” file. You can use any name for the output file.
To read contents of a file and convert it to speech, run a command in the following format:
You can replace “test.txt” with any other file name.
To specify a particular language for synthesizing speech, use a command in the following format:
You can replace “en” with code for other supported languages. To get a list of all supported language codes, run the following command:
To learn more about other command line options available for gTTS, use the following two commands:
$ gtts-cli --help
Conclusion
These are some of the best text to speech apps available for Linux that come with support for synthesizing speech in multiple languages. These TTS apps can be used in a variety of ways, but they are especially useful for improving accessibility for people suffering from visual impairment issues.