Asterisk: Audible Caller ID – June 06, 2009

In addition to hosting phone services for other people, I also host my own phone numbers (personal and business).  I prefer to not have different phones for each line, but I like any phone to be used for either number at any given time.  I haven't gotten around to setting up distinctive ringing for the different lines, but instead, our home computer audibly announces the caller's name and number, and, for the business calls, which menu choice they made.

All that needs to be done on the Asterisk side is:

The timeout and tries parameters are important, because the dialplan will hang until the wget returns. Replace <hostname> with your domain or IP of your home computer.  Replace <port> with an appropriate port number (I also run a "regular" web server on port 80, so I needed to use a different port for this project).

Note, for those of you who consider security an important factor when dealing with random data from the internet, that I filter the caller ID values to try to prevent someone from attempting to hack into my computer.

Kind of crude, and perhaps there is a regular expression filter that would work better, but I looked around for a bit, and couldn't get it to work, so just went the simple route.

On the home computer side, I found code for a small perl server somewhere, and modified it for my needs, and then installed festival, to do the text to speech work.

Note, the "thanks" message that is returned, helps wget end quicker (and note that I print it out before I do the text to speech stuff, so if there is any trouble, or if the TTS takes a while, the dial plan won't get hosed (Hint: various bad things can happen, say, hypothetically during initial development and debugging, which causes your Asterisk server to have lots of calls hanging around and never ending, which causes various problems on the Asterisk side of things; But, I've only heard that from other people, my code always works perfectly the first time)

The only thing that isn't the best about this code is that if you are actually sitting right next to the computer, or if you are already on a call, sometimes the caller ID announcement is too loud and/or too long.  But, for the most part, it is perfect, and the kids know which phone calls they are allowed to answer, and you don't have to look at the caller ID screen to see who it is.