Festival and Asterisk
How to setup Festival with Asterisk for arbitrary text-to-speech in your PBX.
Whilst playing with asterisk, I wanted the feature of text-to-speech, so the PBX can read things such as caller IDs.
The information at voip-info.org would have been helpful, except they couldn't reproduce the conf file verbatim as their in-house wiki parses ((double-bracketed text)) as links, so to help you, I've got a verbatim config file here:
(define (tts_textasterisk string mode) "(tts_textasterisk STRING MODE) Apply tts to STRING. This function is specifically designed for use in server mode so a single function call may synthesize the string. This function name may be added to the server safe functions." (let ((wholeutt (utt.synth (eval (list 'Utterance 'Text string))))) (utt.wave.resample wholeutt 8000) (utt.wave.rescale wholeutt 5) (utt.send.wave.client wholeutt)))
In Debian, the Festival conf file lives in /etc/festival.scm. Paste this into it, then restart Festival using its init script. Now in Asterisk's extensions.conf, you can call it like so:
exten =>2,1,Festival(Hi\, you are being called by)
exten =>2,n,Festival($CALLERID)
Don't forget to escape commas and such. (OK, this was a bad example, as you'd just use SayDigits() in this case)




comments
in Centos
yum install festival*
nano /etc/asterisk/festival.conf
nano /usr/share/festival/festival.scm
******************************************
;; Enable access to localhost (needed by debian users)
(set! server_access_list '("localhost\\.localdomain" "localhost"))
;;; Command for Asterisk begin
(define (tts_textasterisk string mode)
"(tts_textasterisk STRING MODE)
;Apply tts to STRING. This function is specifically designed for
;use in server mode so a single function call may synthesize the string.
;This function name may be added to the server safe functions."
;"the line below is shown incorrectly in this wiki 1 hour wasted :( add two brackets
;before wholeutt and at the end of the line"
(let ((wholeutt (utt.synth (eval (list 'Utterance 'Text string)))))
(utt.wave.resample wholeutt 8000)
(utt.wave.rescale wholeutt 5)
(utt.send.wave.client wholeutt)))
;;; Command for Asterisk end