Home » Technology » Asterisk TTS: Today in History 2.0 & Yesteryear’s Time of Day

The Most Versatile VoIP Provider: FREE PORTING

Asterisk TTS: Today in History 2.0 & Yesteryear’s Time of Day

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 upgraded 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 of interest from HistoryOrb.com and play the results back to you over the phone using Google TTS. 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 instantaneously.

As a bonus, there’s TrimLine’s new Time of Day application for your Asterisk server that works just like it did in yesteryear. You can read all about it and install it from this link.

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 Today in History 2.0 in just a few seconds. For other users, you’ll need an Asterisk server with PHP5 and Flite to handle portions of the text-to-speech. No extras are needed for the Time of Day application.

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 dialplan, you’re ready to go. For a quick demo, dial 1-650-308-9946.

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 Google’s TTS engine is used to convert the text file into /tmp/today.wav. The dial plan code 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:

cd /root
wget http://bestof.nerdvittles.com/applications/today/today2.pbx
chmod +x today2.pbx
./today2.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:


cd /var/lib/asterisk/agi-bin
wget http://bestof.nerdvittles.com/applications/today/today.tgz
tar zxvf today.tgz
rm -f today.tgz
asterisk -rx "dialplan reload"

Upgrading from Today in History 1.0. If you used this script previously, a couple of ugly things have happened to make it stop working. First, Yahoo dropped support for their Today in History RSS feed. And then Cepstral released an upgrade which no longer lets you create .wav files from a text file without paying an additional $200 license fee. So the new release doesn’t use Cepstral. Everything is handled (and handled well) by the Google TTS engine… which is free to use.

If you have an older version of Cepstral that still permits the creation of .wav files, then you can upgrade just the original AGI script. Log into your server as root and issue the following commands:

cd /var/lib/asterisk/agi-bin
rm nv-today.php
wget http://bestof.nerdvittles.com/applications/today/today.zip
unzip today.zip
chown asterisk:asterisk nv-today.php
chmod +x nv-today.php

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 will be played back over your phone. To eliminate the pause the first time the application is run each day, simply add the crontab entry as outlined above. Enjoy!

Originally published: Monday, August 6, 2012


Astricon 2012. Astricon 2012 will be in Atlanta at the Sheraton beginning October 23 through October 25. We hope to see many of you there. We called Atlanta home for over 25 years so we’d love to show you around. Be sure to tug on my sleeve and mention you’d like a free PIAF Thumb Drive. We’ll have a bunch of them to pass out to our loyal supporters. Nerd Vittles readers also can save 20% on your registration by using coupon code: AC12VIT.



Need help with Asterisk? Visit the PBX in a Flash Forum.
Or Try the New, Free PBX in a Flash Conference Bridge.


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.


 

Special Thanks to Our Generous Sponsors


FULL DISCLOSURE: ClearlyIP, Skyetel, Vitelity, DigitalOcean, Vultr, VoIP.ms, 3CX, Sangoma, TelecomsXchange and VitalPBX have provided financial support to Nerd Vittles and our open source projects through advertising, referral revenue, and/or merchandise. As an Amazon Associate and Best Buy Affiliate, we also earn from qualifying purchases. We’ve chosen these providers not the other way around. Our decisions are based upon their corporate reputation and the quality of their offerings and pricing. Our recommendations regarding technology are reached without regard to financial compensation except in situations in which comparable products at comparable pricing are available from multiple sources. In this limited case, we support our sponsors because our sponsors support us.

BOGO Bonaza: Enjoy state-of-the-art VoIP service with a $10 credit and half-price SIP service on up to $500 of Skyetel trunking with free number porting when you fund your Skyetel account. No limits on number of simultaneous calls. Quadruple data center redundancy. $25 monthly minimum spend required. Tutorial and sign up details are here.

The lynchpin of Incredible PBX 2020 and beyond is ClearlyIP components which bring management of FreePBX modules and SIP phone integration to a level never before available with any other Asterisk distribution. And now you can configure and reconfigure your new Incredible PBX phones from the convenience of the Incredible PBX GUI.

VitalPBX is perhaps the fastest-growing PBX offering based upon Asterisk with an installed presence in more than 100 countries worldwide. VitalPBX has generously provided a customized White Label version of Incredible PBX tailored for use with all Incredible PBX and VitalPBX custom applications. Follow this link for a free test drive!
 

Special Thanks to Vitelity. Vitelity is now Voyant Communications and has halted new registrations for the time being. Our special thanks to Vitelity for their unwavering financial support over many years and to the many Nerd Vittles readers who continue to enjoy the benefits of their service offerings. We will keep everyone posted on further developments.
 



Some Recent Nerd Vittles Articles of Interest…