Text-to-speech in PHP


It’s been a while since I’ve played with the open source Festival TTS software, and I’m pretty impressed with the quality of the speech output. Some of the voices that are available sound so much better than the old diphone-based voices that evoke WOPR from War Games.

This got me thinking it’d be fun to integrate some of this functionality into a web application. A quick search and I discovered Tony Bhimani’s Linux Text-To-Speech Tutorial which has a sample PHP application that uses the Festival text2wave utility and the lame mp3 encoder to produce mp3 files from user submitted text.

I mentioned that some of the voices are pretty outstanding. In particular, the “unit selection” voices, demonstrated on the Festival demo page, are able to synthesize a lot of sentences with few noticeable glitches. These voices sound so nice because they contain a much larger database of common sound units, only falling back on heavy processed output on less common utterances. There’s a howto and discussion over on Ubuntu Forums that’ll guide you through installing and using the more enhanced voices with Festival. With a decent voice file, Festival, and an adaptation of Tony’s PHP text-to-speech demonstration, it wouldn’t be too hard to add audio output to your blog or create a script that turns your RSS feeds into a podcast for the daily commute.

Have any of your own text-to-speech ideas or demos? Please share them in the comments!

Tony Bhimani – PHP Text-To-Speech Example
The Festival Speech Synthesis System
HOWTO: Make Festival TTS Use Better Voices

4 thoughts on “Text-to-speech in PHP

  1. kyoorius says:

    Here’s a little hack I did back when m-w.com first introduced their “hear the word” feature on their site.
    You need to have popups enabled because the javascript pops up the audio into a separate window.


    The source code is linked from that page also.

  2. Joel says:

    but isn’t this what the txt2wav() function has been doing since last year?

  3. marvindelacruz says:

    sir for xample sir i want to make a voice dictionary how can i be able to translate the text from my data base into speech please help me sir plese email me if you know it thank u sir marvindelacruz156@gmail.com

Comments are closed.

Discuss this article with the rest of the community on our Discord server!


Maker Faire Bay Area 2023 - Mare Island, CA

Escape to an island of imagination + innovation as Maker Faire Bay Area returns for its 15th iteration!

Buy Tickets today! SAVE 15% and lock-in your preferred date(s).