Add speech to your Fedora system

By default, Fedora Workstation ships a small package called espeak. It adds a speech synthesizer — that is, text-to-speech software.

In today’s world, talking devices are nothing impressive as they’re very common. You can find speech synthesizers even in your smartphone, a product like Amazon Alexa, or in the announcements at the train station. In addition, synthesized voices are nowadays more or less similar to human speech. We live in a 1980s science fiction movie!

The voice produced by espeak may sound a bit primitive compared to the aforementioned tools. But at the end of the day espeak produces good quality speech. And whether you find it useful or not, at least it can provide some amusement.

Running espeak

In espeak you can set various parameters using command line options. Examples include:

  • amplitude (-a)
  • pitch adjustment (-p)
  • speed of sentences (-s)
  • gap between words (-g)

Each of these options produces various effects and may help you achieve a cleaner voice.

You can also select different voice variants with command line options. For example, try -ven+m3 for a different English male voice, and -ven+f1 for a female one. You can also use different languages. For a list, run this command:

espeak --voices

Note that many languages other than English are experimental attempts.

To create a WAV file instead of actually speaking something, use the -w option:

espeak -w out.wav "Audio file test"

The espeak utility also reads the content of a file for you.

espeak -f plaintextfile

Or you can pass the text to speech from the standard input. In this way, as a simple example, you can build a talking box that alerts you to an event using a voice. Your backup is completed? Add this command to the end of your script:

echo "Backup completed" | espeak -s 160 -a 100 -g 4

Suppose an error shows up in a log file:

tail -1F /your/log/file | grep --line-buffered 'ERROR' | espeak

Or perhaps you want a speaking clock telling you every minute what time it is:

while true; do date +%S | grep '00' && date +%H:%M | espeak; sleep 1; done
As you can guess, use cases are limited only by your imagination. Enjoy your new talking Fedora system!
Using Software

8 Comments

  1. Feel free to continue the fun:

    bottles=100;
    while [ $bottles -gt 0 ];
    do espeak “$bottles bottles of beer on the wall, $bottles bottles of beer, take one down pass it around”; (( bottles -= 1 )); espeak “$bottles bottles of beer on the wall”;
    done

    ….I don’t know why that is my first thought of what needs to be done with espeak.

    • Pedro Doria Meunier

      brilliant! 😀

    • Logan Byrd

      Excellent! This didn’t work for me as is, though. I had to echo it and pipe it into espeak as in the article, or espeak would ignore everything after the first word (the space terminated the espeak command despite the quotes).

      Updated version for others who ran into this and still want to have a laugh:

      bottles=100;
      while [ $bottles -gt 0 ];
      do echo “$bottles bottles of beer on the wall, $bottles bottles of beer, take one down pass it around” | espeak; (( bottles -= 1 )); eecho “$bottles bottles of beer on the wall” | espeak;
      done

  2. Mehdi

    This is super cool! I did not know of speech in Fedora

  3. VfioGaming

    that was very funny 🙂

    i love you guys !!!

    p.s. the man voice is a bit scary . i change it with : espeak -v female5

  4. Maimela

    i’m looking for support for a kensington verimark (finger print scanner app for linux, it only works for windows hello but i believe someone out there knows how to use it in linux)

  5. arthur

    Is there any software that does the opposite in that it takes speech and converts it into text?

    • @arthur: You might be interested in OpenSTT although it’s not ready yet if I understand correctly. There are other projects like Kaldi but these are oriented toward building tools as opposed to end-users.

Comments are Closed

The opinions expressed on this website are those of each author, not of the author's employer or of Red Hat. Fedora Magazine aspires to publish all content under a Creative Commons license but may not be able to do so in all cases. You are responsible for ensuring that you have the necessary permission to reuse any work on this site. The Fedora logo is a trademark of Red Hat, Inc. Terms and Conditions