PHP Extension for the Cepstral Text-to-Speech Engine
C++ C PHP
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md Create README.md Mar 23, 2015
cg711.cc
cg711.h No commit message Jan 11, 2011
config.m4 - some config.m4 fixups Mar 26, 2011
cswift.cc
cswift.h - fixed support for 16khz sample rates (not supported by GSM) Mar 26, 2011
php_swift.cc - fixed support for 16khz sample rates (not supported by GSM) Mar 26, 2011
php_swift.h - fixed support for 16khz sample rates (not supported by GSM) Mar 26, 2011
test.php - fixed support for 16khz sample rates (not supported by GSM) Mar 26, 2011

README.md

php_swift_tts - a PHP extension for the Swift text-to-speech engine.

The swift text-to-speech engine is the engine used for the Cepstral Text-to-Speech Voices

This extension requires the libswift, libceplang_en and libceplex_us librarys included with any Cepstral Text-to-Speech voice, and supports any 16khz and 8khz voices installed on the system.

This extension supports multiple audio output formats, including:

  • PCM (RAW audio)
  • u-law / a-law (logarithmically encoded RAW audio)
  • WAV (RAW audio)
  • GSM (when compiled with the libgsm library)
  • MP3 (when compiled with the libmp3lame library)

A simple example:


//
// create the new TTS object
//
$tts = new SwiftTTS();

//
// set a voice to use for generation
//
$tts->setVoice("Allison");

//
// generate text, and return a stream for the audio
//
$s = $tts->generate("hello my name is allison", SwiftTTS::FORMAT_WAV);
if ($s !== false)
{
    //
    // write the stream contents to a file
    //
    file_put_contents("audio.wav", $s);
}

Get an array of available voices:

//
// create the new TTS object
//
$tts = new SwiftTTS();

//
// get a list of available voices
//
$voices = $tts->getVoices();

//
// show the voices
//
print_r($voices);

this produces:


Array
(
    [Allison-8kHz] => Array
        (
            [id] => voice
            [path] => /opt/swift/voices/Allison-8kHz
            [version] => 5.1.0
            [buildstamp] => 2008-04-07 15:02:17 EDT <sisyphus@flea>
            [sample_rate] => 8000
            [license_key] =>
            [language_tag] => en-us
            [language_name] => US English
            [language_version] => 0.0.0
            [lexicon_name] => unknown
            [lexicon_version] => 0.0.0
            [speaker_name] => Allison-8kHz
            [speaker_gender] => Female
            [speaker_age] => 28
        )

    [William] => Array
        (
            [id] => voice
            [path] => /opt/swift/voices/William
            [version] => 5.1.0
            [buildstamp] => 2007-10-12 00:39:32 EDT <sisyphus@moth>
            [sample_rate] => 16000
            [license_key] => 
            [language_tag] => en-us
            [language_name] => US English
            [language_version] => 0.0.0
            [lexicon_name] => unknown
            [lexicon_version] => 0.0.0
            [speaker_name] => William
            [speaker_gender] => male
            [speaker_age] => 30
        )
)

Basic Installation


# cd php-swift-tts
# phpize
# ./configure --with-swift_tts=<path to swift libraries>
# make
# make install

Optional Configure Arguments


To build with MP3 support
  --with-lame-dir=DIR

To build with GSM support
  --with-gsm-dir=DIR