Synthesizing Voice From the Command Line

September 23rd, 2009 by Mitch Frazier in

Your rating: None Average: 3.8 (4 votes)

I don't do a lot of audio/video stuff with my system, but the other day I had the urge to see if there was some voice synthesis software available on Linux and it turned out that I already had it installed: it's called Festival. Turns out there are a number of voice synthesis and analysis packages available.

Festival is, according to the website:

Festival offers a general framework for building speech synthesis systems as well as including examples of various modules. As a whole it offers full text to speech through a number APIs: from shell level, though [sic] a Scheme command interpreter, as a C++ library, from Java, and an Emacs interface. Festival is multi-lingual (currently English (British and American), and Spanish) though English is the most advanced.

As far as simple commands, Festival comes with two: saytime and text2wave. Saytime does what you would expect, it speaks the time (as well as outputting the spoken text to stdout). Note though, the time that is output tends to be less than specific:

$ saytime
The time is now, just after half past 10, in the morning.

A wave file of the output is attached (time.wav).

The second command that comes with Festival is text2wave which converts text read from stdin to a .wav file output:

$ echo Your job has completed | text2wave >job.wav
$ aplay job.wav

# OR
$ echo Your job has completed | text2wave | aplay

The wave file is attached (job.wav).

If these commands do not exist on your system you will need to install the festival package. For other voice related packages search the web or check the list here on linux-sound.org

__________________________

Mitch Frazier is an Associate Editor for Linux Journal and the Web Editor for linuxjournal.com.

AttachmentSize
job.wav58.8 KB
time.wav140.98 KB


Special Magazine Offer -- Free Gift with Subscription
Receive a free digital copy of Linux Journal's System Administration Special Edition as well as instant online access to current and past issues. CLICK HERE for offer

Linux Journal: delivering readers the advice and inspiration they need to get the most out of their Linux systems since 1994.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous's picture

Festival voice synthesis software

On September 30th, 2009 Anonymous (not verified) says:

Hey,
I've been using Festival for 2 years. I use it mainly to get other people's attention. It's easy, it's fun and it's no hassle to install on Mandriva 2008.

Kyle Brandt's picture

Commercial text to speech for Linux

On September 24th, 2009 Kyle Brandt (not verified) says:

Cepstral is very good and has Linux versions that work well. However, it is not free. I found the voices to be much better quality than festival.

http://cepstral.com/

metalx2000's picture

espeak

On September 23rd, 2009 metalx2000 says:

espeak is another great program for Synthesizing Voice From the Command Line.

To read a string:
$ espeak "Hello World"

or to read a text file:
$ espeak -f text.txt

To save the output it a WAV file:
$ espeak "Hello World" -w my.wav

It has other options to (Voice, speed, pitch)
Not that one way is better then the other. I just wanted to show that there is another way to do it.

__________________________

http://www.bashscripts.info/
Learn to Take Control of Your Computer, NOW!!!

Kyle's picture

eSpeak

On September 24th, 2009 Kyle (not verified) says:

Ubuntu comes with eSpeak by default. I find that it sounds much better than Festival and I can listen to it for much longer. Orca, which is the screen reader I use on Ubuntu speaks through either speech-dispatcher or gnome-speech, both of which have an eSpeak driver. The comment to which I am replying gives good instructions for how to create a .wav file with eSpeak from the command line.

Post new comment

Please note that comments may not appear immediately, so there is no need to repost your comment.
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <pre> <ul> <ol> <li> <dl> <dt> <dd> <i> <b>
  • Lines and paragraphs break automatically.

More information about formatting options

Newsletter

Each week Linux Journal editors will tell you what's hot in the world of Linux. You will receive late breaking news, technical tips and tricks, and links to in-depth stories featured on www.linuxjournal.com.
Sign up for our Email Newsletter

Tech Tip Videos

From the Magazine

December 2009, #188

If last month's Infrastrucuture issue was too "big" for you then try on this month's Embedded issue. Find out how to use Player for programming mobile robots, build a humidity controller for your root cellar, find out how to reduce the boot time of your embedded system, and if you're new to embedded systems find out the basics that go into one. You can also read about the Beagle Board, the Mesh Potato and a spate of other interestingly named items. And along with our regular columns don't miss our new monthly column: Economy Size Geek.


Read this issue