Ever wished your Asterisk® server could harness the power of a 10,000 CPU Supercomputer to answer virtually any question you can dream up about the world we live in? Well, so long as it’s for non-commercial use, today’s your lucky day. Apple demonstrated with Siri™ just how amazing this technology could be by coupling Wolfram Alpha® to a speech-to-text engine on the iPhone about 5 years ago. And, thanks to Google’s new speech transcription engine and Wolfram Alpha’s API, you can do much the same thing with any Asterisk server. Today, we’ll walk you through the 5-minute setup with XiVO or Wazo.
Five years ago, we had such a good name for this project, Iris, which is Siri spelled backwards. You know the backwards sister and all of that. At last count, there now are about two dozen Iris apps for Android phones so we give up. Instead we give you 4747. You can figure it out from there.
When people ask what exactly Wolfram Alpha is, our favorite answer was provided by Ed Borasky: “It’s an almanac driven by a supercomputer.”
That’s an understatement. It’s a bit like calling Google Search a topic index. Unlike Google which provides links to web sites that can provide answers to queries, Wolfram Alpha provides specific and detailed answers to almost any question. Here are a few examples (with descriptions of the functionality) to help you wrap your head around the breadth of information. For a complete list of what’s available, visit Wolfram Alpha’s Examples by Topic. Type a sample query here or use the examples below with your phone once you complete the install today.
Weather in Charleston South Carolina
Weather forecast for Washington D.C.
Next solar eclipse
Who won the 1969 Superbowl? (Broadway Joe)
What planes are now flying overhead? (flying over your server’s location)
Ham and cheese sandwich (nutritional information)
Holidays 2017 (summary of all holidays for 2012 with dates and DOW)
Medical University of South Carolina (history of MUSC)
Star Trek (show history, air dates, number of episodes, and more)
Apollo 11 (everything you ever wanted to know)
Cheapest Toaster (brand and price)
Battle of Gettysburg (sad day 🙂 )
Daylight Savings Time 2017 (date ranges and how to set your clocks)
Tablets by Motorola (pricing, models, and specs from Best Buy)
Doughnut (you don’t wanna know)
Snickers bar (ditto)
Weather (local weather at your server’s location)
Best Question of the Day Award: “How much wood could a woodchuck chuck if a woodchuck could chuck wood?” And the answer: “A woodchuck would chuck all the wood he could chuck if a woodchuck could chuck wood. According to the tongue twister, although the paper ‘The Ability of Woodchucks to Chuck Cellulose Fibers’ by P.A. Paskevich and T.B. Shea in Annals of Improbable Research vol. 1, no. 4, pp. 4-9, July/August 1995, concluded that a woodchuck can chuck 361.9237001 cubic centimeters of wood per day.”
Implementation Overview. Today what we’re going to demonstrate is how to configure your Asterisk® server so that you can pick up any phone on your system, dial 4-7-4-7 and ask a question. Then we’ll send your question to Google to convert the spoken words into text. Next, we’ll pass Google’s text translation along to Wolfram Alpha which will provide a plain text answer to your question. Finally, we’ll take that plain text response and use the Flite TTS engine to deliver the results to you over the phone.
Prerequisites. For openers, you’ll need two things: a speech recognition key from Google and a free Wolfram Alpha account. We’ll be using Incredible PBX™ for XiVO and Wazo to demonstrate the setup because almost all the pieces are in place to make this easy. It’s certainly possible to do what we’re demonstrating on other Asterisk server platforms once you get all of the dependencies resolved. But we’ll leave that for the do-it-yourselvers.
Legal Disclaimer. What we’re demonstrating today is how to use two publicly accessible web resources to harness the power of a supercomputer to respond to your queries using a phone connected to an Asterisk server. We’re assuming that both Google and Wolfram Alpha have their legal bases covered and have a right to provide the public services they are offering. We are not vouching for them or the services they are offering in any way. By using our scripts, YOU AGREE TO ASSUME ALL RISKS, LEGAL AND OTHERWISE, ASSOCIATED WITH USE OF THESE FREELY ACCESSIBLE WEB TOOLS. NO WARRANTY EXPRESS OR IMPLIED IS BEING PROVIDED BY US INCLUDING ANY IMPLIED WARRANTY OF FITNESS FOR USE OR MERCHANTABILITY. You, of course, have an absolute right not to use our code if you have reservations of any kind or are unwilling to assume all risks associated with such use. Sorry for the legalese, but it’s the time in which we live I’m afraid. Plain English: “Don’t Shoot the Messenger!”
Configuring XiVO/Wazo for Voice Recognition. As we noted, all of the pieces already are in place on the Incredible PBX for XiVO/Wazo platform to support voice recognition. All you’ll need to do is obtain a key from Google and plug it into the existing voice recognition script that’s already in place. If you haven’t already done this, start here.
Getting a Wolfram Alpha Account. As you can imagine, there have to be some rules when you’re using someone else’s supercomputer for free. So here’s the deal. It’s free for non-commercial, personal use once you sign up for an account. But you’re limited to 2,000 queries a month which works out to almost 70 queries a day. Every query requires your personal application ID, and that’s how Wolfram Alpha keeps track of your queries. Considering the price, we think you’ll find the query limitation pretty generous compared to other web resources.
Sign up for a free Wolfram Alpha API account here. Just provide your email address and set up a password. It takes less than a minute. Log into your account and click on Get An App ID. Make up a name for your application and write down (and keep secret) your APP-ID code. That’s all there is to getting set up with Wolfram Alpha. If you want to explore costs for commercial use, there are links to let you get more information.
Installing Wolfram Alpha Application. Here are the steps to use the one-click installer. Log into your XiVO or Wazo server as root and issue the following commands. Plug in your Wolfram Alpha APP-ID when prompted.
tar zxvf setup-wolfram-wazo.tar.gz
rm -f setup-wolfram-wazo.tar.gz
Taking Wolfram Alpha for a Spin. Some sample commands have been documented above to get you started. Just pick up a phone on your Wazo server and dial 4747. When prompted, say one of the commands and press the pound key. Your command will be sent to Google for translation, and then the text result will be played back using Flite or Cepstral. If it says what you meant to say, press 1 to launch the Wolfram Alpha connection and get the answer to your question. If not, press * and try again.
You also can watch the progress of your calls on the Asterisk CLI. We’ve found the Google speech-to-text transcription to be extremely accurate in quiet rooms. One of the variables returned in the [4747@from-internal:5] entry on the Asterisk CLI includes a transcription accuracy measurement which is shown as a decimal number less than 1. This gives you an idea of how well Google is understanding your accent. If the number consistently falls below .9, you may want to move out of the Deep South and try again after you lose your accent. 😉
Tweaking the Abbreviations List. Translating abbreviations into speech is a tricky business, and Flite does a pretty lousy job on some of them. We’ve started the beginnings of an abbreviation list which you will find in the function section of 4747.php which is stored in /var/lib/asterisk/agi-bin. It’s easy to add additional entries. Just clone one of the entries that’s already there. For example, here’s the line that translates Jr. into Junior. HINT: Be careful to surround most unpunctuated abbreviations with spaces, or you may get unexpected results when a word actually begins or ends with the same letters.
$response = str_replace(“Jr.”,”junior”,$response);
Originally published: Tuesday, December 6, 2016
Need help with Asterisk? Visit the PBX in a Flash Forum.
Coming Soon to Nerd Vittles: The Autonomous Car
Longer version of self-driving demo with Paint It Black soundtrack https://t.co/YuUmyEaCgR
— Elon Musk (@elonmusk) November 19, 2016
Special Thanks to Our Generous Sponsors
Awesome Vitelity Special. Vitelity has generously offered a terrific discount for Nerd Vittles readers. You now can get an almost half-price DID 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. When you use our special link to sign up, Nerd Vittles gets a few shekels down the road to support our open source development efforts 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 our 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 and four simultaneous channels for just $3.99 a month. To check availability of local numbers and tiers of service from Vitelity, click here. NOTE: You can only use the Nerd Vittles sign-up link to order your DIDs, or you won’t get the special pricing! 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. Any balance is refundable if you decide to discontinue service with Vitelity.
3CX is a software PBX that’s easy to install & manage. It includes integrated softphones, WebRTC conferencing and essential add-ons out of the box, at no additional cost. Try the free edition at www.3cx.com. Better yet, download the PIAF5 ISO powered by 3CX. Free version includes support for 8 simultaneous calls with a SIP trunk.
Some Recent Nerd Vittles Articles of Interest…