First Release of PHP Swift TTS Extension

I’m happy to announce the first release of the Swift Text-To-Speech PHP extension; the swift engine is the free TTS engine provided with any Cepstral TTS voice. A lot of Asterisk fans out there will recognize the Cepstral Allison voice, as the default voice for Asterisk installations.

The extension will only work on systems support by the Swift engine, and has only been tested (so far) on Linux (CentOS).

The extension will generate audio based on the text provided, and can be exported in several different audio 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 on how to use this:

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

// set a voice to use for generation

// 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);

For more details, and to download the current version, see the Google Code page.

2 thoughts on “First Release of PHP Swift TTS Extension

  1. mikerosss

    Pretty nice post. I just stumbled upon your blog and wanted to say that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I hope you write again soon!

  2. phpconnect

    I am trying to compile the using make but i am getting following errors
    /bin/sh /var/www/html/apc_test/phpext/php-swift-tts_1.0/libtool –mode=compile g++ -I. -I/var/www/html/apc_test/phpext/php-swift-tts_1.0 -DPHP_ATOM_INC -I/var/www/html/apc_test/phpext/php-swift-tts_1.0/include -I/var/www/html/apc_test/phpext/php-swift-tts_1.0/main -I/var/www/html/apc_test/phpext/php-swift-tts_1.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/var/www/html/apc_test/phpext/php-swift-tts_1.0/Cepstral_Amy_x86-64-linux_5.1.0//include -DHAVE_CONFIG_H -c /var/www/html/apc_test/phpext/php-swift-tts_1.0/ -o php_swift.lo
    g++ -I. -I/var/www/html/apc_test/phpext/php-swift-tts_1.0 -DPHP_ATOM_INC -I/var/www/html/apc_test/phpext/php-swift-tts_1.0/include -I/var/www/html/apc_test/phpext/php-swift-tts_1.0/main -I/var/www/html/apc_test/phpext/php-swift-tts_1.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/var/www/html/apc_test/phpext/php-swift-tts_1.0/Cepstral_Amy_x86-64-linux_5.1.0//include -DHAVE_CONFIG_H -c /var/www/html/apc_test/phpext/php-swift-tts_1.0/ -fPIC -DPIC -o .libs/php_swift.o
    /var/www/html/apc_test/phpext/php-swift-tts_1.0/ In function ‘void zif_swift_getVoices(int, zval*, zval**, zval*, int)’:
    /var/www/html/apc_test/phpext/php-swift-tts_1.0/ error: invalid conversion from ‘const char*’ to ‘char*’
    /var/www/html/apc_test/phpext/php-swift-tts_1.0/ error: initializing argument 2 of ‘int add_assoc_zval_ex(zval*, char*, uint, zval*)’
    make: *** [php_swift.lo] Error 1

    can you tell me what is the problem?

Leave a Reply

Your email address will not be published. Required fields are marked *