If you're a history buff and want a convenient way to find out everything that ever happened Today in History, then this week's text to speech (TTS) application for Asterisk® should be just what you need. Pick up any phone connected to your Asterisk system and dial T-O-D-A-Y (86329 for the spelling-impaired). The script will retrieve today's historical events and today's birthdays of interest from Yahoo News and play the results back to you over the phone using either Flite or Cepstral to handle the TTS translation. To speed up the retrieval process, you can also set this up as a cron job to download the latest events each day while you're sleeping. Thereafter, when you dial T-O-D-A-Y, the results are played back for callers instantaneously.
Prerequisites. If you're using PBX in a Flash, then all of the tools you'll need are already in place. And we have a script for you that will install the application in just a few seconds. For other users, you'll need an Asterisk server with PHP5 and either Flite or Cepstral to handle the text-to-speech chores.
Overview. If you've previously installed other Nerd Vittles text to speech applications, then the drill this time around is quite similar. There's a PHP/AGI script which gets stored in /var/lib/asterisk/agi-bin. In this script (nv-today.php), you can change the default Flite TTS engine to Cepstral by changing the $ttspick variable setting from 0 to 1. Then there is a snippet of dialplan code that needs to be added to the [from-internal-custom] context in extensions_custom.conf for FreePBX installations. Once you reload your Asterisk dialplan, you're ready to go.
How It Works. The PHP/AGI script only does real work once a day. It always checks to see if there is an existing /tmp/today.txt file with today's file stamp. If there is, it exits gracefully. If today's file doesn't exist or if the file's time stamp is earlier than midnight, then the script downloads the latest information for today in history and creates a text file of the data. Then either the Flite or Cepstral TTS engine is called to convert the text file into /tmp/today.wav. The dial plan code is used to answer calls to extension 86329. Then it runs the PHP/AGI script, and finally it plays back /tmp/today.wav. Note: The PHP/AGI script, if run as a cron job or from the command prompt, should never be run as the root user, but only as the asterisk user. Otherwise, the today.txt and today.wav files cannot be replaced by the script when it subsequently is run from the dialplan.
Script Installation. If you're using PBX in a Flash, log into your server as root and issue the following commands:
chmod +x today.pbx
Automatic Updates Using crontab. If you'd like to automatically generate the Today in History files each day, add the following entry to the bottom of /etc/crontab:
01 0 * * * asterisk /var/lib/asterisk/agi-bin/nv-today.php
Manual Installation. For those using a different Asterisk aggregation that includes PHP5, FreePBX, and Flite, add this code to /etc/asterisk/extensions_custom.conf in the [from-internal-custom] context:
exten => 86329,1,Answer
exten => 86329,2,Wait(1)
exten => 86329,3,Set(TIMEOUT(digit)=7)
exten => 86329,4,Set(TIMEOUT(response)=10)
exten => 86329,5,Flite(Please stand bye while we retrieve: Today in History.)
exten => 86329,6,AGI(nv-today.php)
exten => 86329,7,Playback(/tmp/today)
exten => 86329,8,Wait(1)
exten => 86329,9,Hangup
Then issue the following commands from the command prompt after logging in as root:
rm -f today.zip
cp nv-today.php /var/lib/asterisk/agi-bin/nv-today.php
chmod 775 /var/lib/asterisk/agi-bin/nv-today.php
chown asterisk:asterisk /var/lib/asterisk/agi-bin/nv-today.php
asterisk -rx "dialplan reload"
Running the Application. Now you're ready for a test run. Pick up any phone connected to your Asterisk system and dial T-O-D-A-Y. After a brief pause to download the data, today's events in history and today's birthdays will be played back over your phone using your favorite text to speech voice. To eliminate the pause the first time the application is run each day, simply add the crontab entry as outlined above. Enjoy!
Free DIDs While They Last. Sipgate is giving away a free U.S. DID with free incoming calls plus 200 free minutes for outbound calls. Better hurry. Here's the trunk setup for FreePBX-based systems:
Trunk name: sipgate
Registration Strong: ACCTNO:ACCTPW@sipgate.com/YOUR-DID-NUMBER
ACCTNO is the account number assigned to your sipgate account. ACCTPW is the password for your account. YOUR-DID-NUMBER is your 10-digit DID.
Finally create an inbound route using your actual 10-digit DID and assign a destination for the inbound calls.
Need help with Asterisk? Visit the PBX in a Flash Forum.
Or Try the New, Free PBX in a Flash Conference Bridge.
Twitter Magic. If you haven't noticed the right margin of Nerd Vittles lately, we've added a new link to our Twitter feed. If you explore a little, you'll discover that the user interface now brings you instant access to every Twitter feed from the convenience of the Nerd Vittles desktop. Enjoy!
whos.amung.us If you're wondering what your fellow man is reading on Nerd Vittles these days, wonder no more. Visit our new whos.amung.us statistical web site and check out what's happening. It's a terrific resource both for us and for you.
New Vitelity Special. Vitelity has generously offered a new discount for PBX in a Flash users. You now can get an almost half-price DID and 60 free minutes from our special Vitelity sign-up link. If you're seeking the best flexibility in choosing an area code and phone number plus the lowest entry level pricing plus high quality calls, then Vitelity is the hands-down winner. Vitelity provides Tier A DID inbound service in over 3,000 rate centers throughout the US and Canada. And, when you use our special link to sign up, the Nerd Vittles and PBX in a Flash projects get a few shekels down the road while you get an incredible signup deal as well. The going rate for Vitelity's DID service is $7.95 a month which includes up to 4,000 incoming minutes on two simultaneous channels with terminations priced at 1.45¢ per minute. Not any more! For PBX in a Flash users, here's a deal you can't (and shouldn't) refuse! Sign up now, and you can purchase a Tier A DID with unlimited incoming calls for just $3.99 a month and you get a free hour of outbound calling to test out their call quality. To check availability of local numbers and tiers of service from Vitelity, click here. Do not use this link to order your DIDs, or you won't get the special pricing! After the free hour of outbound calling, Vitelity's rate is just 1.44¢ per minute for outbound calls in the U.S. There is a $35 prepay when you sign up. This covers future usage and any balance is fully refundable if you decide to discontinue service with Vitelity.
Some Recent Nerd Vittles Articles of Interest...