Cepstral-weather-reports

Credit goes to: http://www.trixbox.org/forums/trixbox-forums/open-discussion/mini-howto-install-cepstral-asterisk-weather-station-zip-nerdv

The following assumes you have a working trixbox system already in place with at least one working phone extension.

Step 1 - Reference arrticle: http://nerdvittles.com/index.php?m=200801

Log into your trixbox system via ssh as root and enter the following commands:

cd /root
wget http://downloads.cepstral.com/cepstral/i386-linux/Cepstral_Allison-8kHz_...
tar -zxvf Cepstral*
cd Cepstral_Allison-8kHz_i386-linux_4.2.1
./install.sh

After you've read the license, type yes to install the voice on your system, not -yes- as the instructions imply. Don't ask how I know. Accept the default locations for the installation. When the installation completes, issue the following command:

echo /opt/swift/lib > /etc/ld.so.conf.d/cepstral.conf
ldconfig

This places the Cepstral_Allison voice in /opt/swift/voices/
You can download other voices from Cepstral at http://www.cepstral.com/cgi-bin/downloads?type=1143746987

After installing multiple voices, retrieve a list of installed voices with:

ls /opt/swift/voices

Step 2 - Installing apt-swift. There's another important piece in getting Cepstral to play nicely with Asterisk, apt-swift.

Just issue the following commands to install apt-swift on your trixbox system:

cd /usr/src
wget http://www.loopfree.net/app_swift/app_swift-0.9.1.tar.gz
tar -zxvf app_swift*
rm *.gz
cd app_swift-0.9.1
make
make install

Before proceeding, it is important to note I was unsuccessful at first installing apt-swift per the instructions found here: http://nerdvittles.com/index.php?m=200801

I read somewhere but can't remember where a comment stated the need to install asterisk-devel and gcc so I issued the following command:

yum install gcc asterisk-devel

Then ran

make && make install

and apt-swift compiled and installed successfully.

Step 3 - Finally, you need to add a link in your search path for Cepstral and modify /etc/asterisk/swift.conf to tell it which voice you want to use with Asterisk and then restart Asterisk. Assuming you installed Allison-8kHz, here are the commands.

ln -s /opt/swift/bin/swift /usr/bin/swift
sed -i 's|David-8kHz|Allison-8kHz|' /etc/asterisk/swift.conf
amportal restart

You can now check to see that everything is installed correctly in Asterisk by issuing the command:

asterisk -rx "core show application swift"

You should receive the following response:

-= Info about application 'Swift' =-

[Synopsis]
Speak text through Swift text-to-speech engine.

[Description]
Swift(text) Speaks the given text through the Swift TTS engine.
Returns -1 on hangup or 0 otherwise. User can exit by pressing any key.

Note*** If you have multiple voices installed, nano -w /etc/asterisk/swift.conf to change the voice you wish to use then "amportal restart". This allowed me to try different voices prior to purchasing a license for the voice I will use in production.

Step 4 - Installing NerdVittles Asterisk Weather Station by Zip Code; This part is pretty straight forward but we will need to make adjustments for Cepstral now instead of using Flite.

Follow instructions found here: http://bestof.nerdvittles.com/applications/weather-zip/

Per NerdVittles article found here: http://nerdvittles.com/index.php?m=200802 we will need to make adjustments as follows:

Changing DialPlan Code to Cepstral. Log into your server via ssh as root and edit the extensions_custom.conf file in /etc/asterisk:
nano -w extensions_custom.conf
Now search for the number 947 then press Enter. You'll be positioned on code that looks like the following:

; Weather by Zip Code
exten => 947,1,Answer
exten => 947,2,Wait(1)
exten => 947,3,Set(TIMEOUT(digit)=7)
exten => 947,4,Set(TIMEOUT(response)=10)
;exten => 947,5,Flite("At the beep enter the five digit code for the weather report you wish to retrieve.")
exten => 947,5,Swift("At the beep enter the five digit code for the weather report you wish to retrieve.")
exten => 947,6,Read(ZIPCODE,beep,5)
;exten => 947,7,Flite("Please hold a moment while we contact the National Weather Service for your report.")
exten => 947,7,Swift("Please hold a moment while we contact the National Weather Service for your report.")
exten => 947,8,AGI(nv-weather-zip.php|${ZIPCODE})
exten => 947,9,NoOp(Wave file: ${TMPWAVE})
exten => 947,10,Playback(${TMPWAVE})
exten => 947,11,Hangup

Don't change anything else. When your code looks like that above save your changes by pressing Ctrl-X, then Y, then the Enter key. Reload your Asterisk dialplan to make the changes take effect:

asterisk -rx "dialplan reload"

You could also issue:

amportal restart

Next, complete the steps to install Asterisk Weather Station by Zip Code. After performing the AGI Script Setup you will need to change the PHP application code to accomodate Cepstral.

Step 5 - Changing PHP Application Code to Cepstral. Log into your server via ssh as root and issue the following commands using the name of the PHP file for the application you want to change:

cd /var/lib/asterisk/agi-bin
nano -w nv-weather-zip.php

At the top of the file, you'll notice several lines with variables that can be changed.

//-------- DON'T CHANGE ANYTHING ABOVE THIS LINE ----------------

$debug = 1;
$newlogeachdebug = 1;
$emaildebuglog = 0;
$email = "yourname@yourdomain" ;
$ttspick = 0 ;

//-------- DON'T CHANGE ANYTHING BELOW THIS LINE ----------------

To activate the Cepstral TTS engine, just change the value for $ttspick from 0 to 1. Then save your changes: Ctrl-X, Y, then Enter. Now try out your fancy new weather application using Cepstral by dialing 947 from any phone on your trixbox system.

Step 6 - Licensing Cepstral Voices - You may skip this step or pay for the voices whenever. You will here the voice nagging for you to visit www.cepstral.com until you do so.

After purchasing the license and receiving your key, issue command:

swift --reg-voice

Fill in the blanks with the information you wrote down, and you're all set. Dial 947 from a phone on your system again, and the nag message should be gone.

Your Name: John Q. Public
Company (if applicable): Acme Widgets
Voice: Allison-8kHz
License Key: xx-xxxxxx-xxxxxx-xxxxxx-xxxxxx-xxxxxx
You can license each Cepstral voice for just $29.99 or even cheaper if you find a promocode.

Step 7 - May not apply to all...In my personal experience I have repeated the above steps and each time the script hangsup after failing to read the weather. At the CLI I issued:

asterisk -r
then
set verbose 6

When dialing 947 from my softphone I could see the script stepping through but would never hear the report. Reviewing the log at /var/log/asterisk/nv-weather-zip.txt indicated the report was successfully downloading and I was seeing something like the following towards the bottom of the file:

exec swift "Your report was successfully downloaded. Please stand bye."
200 result=0
SET VARIABLE TMPWAVE tts/tts-86023d82b9aae6fde12517cf987c4802
200 result=1

So the script was completing, but the following dialplan steps were not working correctly:

exten => 947,9,NoOp(Wave file: ${TMPWAVE})
exten => 947,10,Playback(${TMPWAVE})

Finally, I figured out, there was no /var/lib/asterisk/sounds/tts directory so no wave file was being generated. I created the directory and assigned appropriate permissions. 0777 should work.

cd /
mkdir /var/lib/asterisk/sounds/tts
chmod 0777 /var/lib/asterisk/sounds/tts

Now, pick up a phone attached to your trixbox system and dial 947. AMAZING...it works!

If anything is left out, please post corrections.

Credit goes to: http://www.trixbox.org/forums/trixbox-forums/open-discussion/mini-howto-install-cepstral-asterisk-weather-station-zip-nerdv


Wiki Home|Tutorials|Troubleshooting|Additional Scripts and Tricks|Hardware Support