Flite TTS

About

Speech CS CMU

Carnegie Mellon University
5000 Forbes Ave
Pittsburgh, PA 15213
USA

Website: http://www.speech.cs.cmu.edu/flite/

Definition

Flite is a free open source Text-to-Speech engine. Flite (Festival Lite) is a small, fast run-time synthesis engine developed at CMU and primarily designed for small embedded machines and/or large servers.

Languages

American, English

Installation

Unzip and untar the Flite package by using the command:

# tar xvzf flite_V1.x_date.tar.gz

Go to the directory of the Flite and then, type the following command.

# cd flite_V1.x_date
# ./install.sh

Configuration

This is the PHP script used to generate wav files from Flite:

<?php
error_reporting ( E_ALL );

include("config.php");
include("ttslib.php");

if(!defined('DEBUG'))
  error_reporting(0);

debug("Mode debug enabled");

if(isset($_POST["text"])){
  $text = $_POST["text"];
  if(isset($_POST["format"])) $format = $_POST["format"];
  debug(" POST VARIABLES :");
  debug(print_r( $_POST,true));
}elseif(isset($_GET["text"])){
  $text = $_GET["text"];
  if(isset($_GET["format"])) $format = $_GET["format"];
  debug(" GET VARIABLES :");
  debug(print_r( $_GET,true));
}else
  httperror();

debug(" text   = $text");
debug(" format = $format");

switch($format){
  case 'gif':
    headerdebug("Content-Type: image/gif");
    headerdebug('Content-Disposition: attachment; filename="file.gif"');
    break;
  case 'wav':
  default :
    headerdebug("Content-Type: audio/wav");
    headerdebug('Content-Disposition: attachment; filename="file.wav"');
}

$filename=tempnam("/tmp",$ttsname."TMP");
$file=fopen($filename, "w");

debug(" Temp file = $filename");

register_shutdown_function('cleanup',"$filename");
fwrite($file, $text);
fwrite($file, "\n");
fclose($file);

$program = "/usr/bin/flite";
$time_start = microtime(true);
register_shutdown_function('cleanup',"$filename.wav");
exec($program." -f $filename -o $filename.wav", $return, $status);
$time_end = microtime(true);
$texec = $time_end - $time_start;
$outsize=filesize("$filename.wav");

readfile("$filename.wav");

if($enable_record_to_cdr)
register_shutdown_function('cdrrecord',$ttsname,$lang,$status,$texec,$text,$outsize);

register_shutdown_function('garbage',$ttsname);

// vim: set filetype=php expandtab tabstop=2 shiftwidth=2 autoindent smartindent:
?>

The TTS package install the HTTP scripts in:

/var/www/tts/flite

In a default Debian installation, you can test the TTS installation with :

http://yourip/tts/flite/index.php

This web page will generate wav files in PCM 16bit 8kHz mono.

Release Notes

Install the script on your Apache/PHP server. Configure the VoiceXML Browser (Text-to-Speech Option) and restart the VoiceXML interpreter to get the new configuration.

Flite have a dependency to libasound (with Debian install the package libasound2).

Log In