Posts Tagged ‘sample’

Seattle 911 scanner on Tropo for the hackathon

Sunday, August 22nd, 2010

For the Gnomedex hackathon we sponsored this weekend, I spent most of my time helping out teams who were building things using Tropo. But mid-morning today, inspiration struck for my own project. It’s not huge, so I was able to hack it together quickly and it’s a great sample app.

Remember police scanners? You can listen to live radio traffic between police cars. Some people do it for profit, like news reporters or ambulance chasers. Others do it for fun, just to hear what’s going on. The City of Seattle, one of our sponsors publishes their fire department 911 calls in near-real time using services from Socrata, another hackathon sponsor. So I wrote up an app that emulates a police scanner, using 911 dispatches as a data source.

Call a phone number, and Tropo will fetch the current list of 911 data from Socrata and play the incidents over the phone. For demo purposes, we’re only fetching data every 15 minutes and we’re getting any calls from the last 10 hours.

You can grab the code from Github or read it below.

<?php
answer();
sleep(2);
say ('Welcome to the Seattle <say-as interpret-as="vxml:digit">911</say-as> scanner.');
$timer = time();

$data = fetchIncidents();
if (count($data) == 0) {
  say("http://hosting.tropo.com/37423/www/audio/beep-7.mp3";);
}
while(1) {
  $data = fetchIncidents();
  foreach ($data as $incident) {
    say("<speak><paragraph xml:lang='en-us-fmj'>At <say-as interpret-as='address'>{$incident[8]}</say-as> an {$incident[9]}.</paragraph></speak>");
    $timer = time();
  }
  $currTime = time();
  if ($currTime - $timer > 30) {
    say("http://hosting.tropo.com/37423/www/audio/beep-7.mp3";);
  }
  sleep(900);
}

function fetchIncidents() {
  $url = "http://data.seattle.gov/api/views/INLINE/rows.json?method=index";;

  $time = time() - 360000;

  $data = '{"name":"Seattle Real Time Fire 911 Calls","query":{"orderBys":[{"expression":{"columnId": 2354168,"type":"column"},"ascending": false}],"filterCondition":{"value":"AND","children": [{"children":[{"columnId":2354168,"type":" column"},{"value":' . $time . ',"type":"literal"}],"value":" GREATER_THAN","type":"operator"}],"type":" operator"}},"originalViewId": "kzjm-xkqj"}';

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
  curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

  $json = curl_exec ($ch);

  curl_close($ch);

  $data = json_decode($json, true);
  return $data['data'];
}
?>

How the Star Wars hotline was created

Tuesday, June 29th, 2010

In yesterday’s Star Wars hotline post we resurrected the old Empire Strikes Back fan hotline using the recently rediscovered teaser recordings from starwars.com. The post on startwars.com about the old hotline says

This was before the telephone system was completely computerized. Back then, there was a lot of mechanical switching equipment. The first week the system went live, so many people called the number, AT&T couldn’t handle it. They were so overloaded, the system couldn’t even handle generating busy signals to all of the calls. The 800 system for Illinois crashed and shut down for several hours. AT&T insisted that we add additional phone lines.

When we started the company 10 years ago, we started out with a problem statement that we then set out to solve. That problem? “Computer telephony sucks.”

The telephony world has come a long way since the days of the original Empire hotline. Instead of roomfuls of switching equipment, all we needed to build the Empire hotline was 5 lines of PHP code.

<?php
$urls = array('http://www.starwars.com/media/audio/empire1_c3po.mp3', 'http://www.starwars.com/media/audio/empire1_han.mp3', 'http://www.starwars.com/media/audio/empire1_leia.mp3', 'http://www.starwars.com/media/audio/empire1_luke.mp3', 'http://www.starwars.com/media/audio/empire1_vader.mp3');
$key = array_rand($urls,1);
answer();
say($urls[$key] . ' Call back for another message. There are five in all.');
hangup();
?>

The app uses the MP3 recordings stored on starwars.com. If you use an audio URL in your Tropo Say statement, we’ll play it. So the code takes the five urls of the different recordings, selects a random one, then answers the phone and plays the recording. Then it lets you know that you can call back for more messages and hangs up.

That’s a lot simpler than a roomful of switching equipment. And since we work with the carriers, if one of them can’t handle the call volume, we’ll route around them. And you don’t need to add any phone lines. We’ll scale to handle as many calls as you need.

Introducing OpenVoice. Your number, Open Source.

Wednesday, May 19th, 2010

OpenVoiceLong time Tropo developer Zhao Lu launched OpenVoice today. OpenVoice is a virtual number application that can forward calls, handle voicemail (with transcriptions), send and receive SMS, and make outbound calls from your OpenVoice number. And because OpenVoice is built on Tropo, it has built in support for speech recognition and phone numbers are available from around the world.

OpenVoice is built with Ruby on Rails using the Tropo WebAPI to communicate with the phone system, and Tropo has signed on as a contributor to the project. We’ll be using OpenVoice to show off how to build Sophisticated Tropo applications and using the OpenVoice code and use cases to create tutorials for Tropo features. You can bet in the future that when we add a new feature, we’ll describe how to implement it by using OpenVoice as an example.

We’re launching OpenVoice alongside Zhao today at Google I/O and we’ve packed it with all sorts of Google technologies.

  • Android Client
  • Voicemail notifications and transcriptions delivered over Google Talk
  • Call logs displayed on a google map
  • Import contacts from Gmail
  • Some other hidden goodies

In addition to those, we’ve developed a version of OpenVoice that can run on Google App Engine and uses your Google Account as a single signon platform.

Using Tropo as a platform allowed us to create OpenVoice in under 4 man-weeks. We went from idea to implementation in less than a month. Because of the Tropo underpinnings, developers have a full API they can work with to implement features of their own or interact with their phone for them.

Want to see OpenVoice in action? Stop by and visit Voxeo in the Google I/O Sandbox today and tomorrow. Not at I/O? Chris Matthieu, one of the OpenVoice developers put together a 10 minute video overview. Or download a copy of the code from Github and try it out for yourself.

What is Multi-modal?

Tuesday, May 18th, 2010

We’ve talked a bit about how text communications are on the rise, replacing a lot of the voice self service that companies have traditionally offered. Text doesn’t always replace voice, however. With platforms that can work over both voice and text, it’s possible for text to augment the voice channel.

Take the example of directory assistance. Back when I was a kid, you called directory assistance, gave a business name (to a real human!) and they gave you the phone number. You wrote down the number and gave the business a call. Over time, companies started offering a service where they’d transfer you to the number, letting you skip writing it down and dialing yourself. With mobile phones, this service became even more important, as you’re often calling for assistance when you can’t stop and write something down.

An issue sometimes arises, however, when the number is busy. Or you get disconnected and have to call back. Since you didn’t pick up the number from the directory assistance but were transferred by them, you end up having to call back, ask for the business again, and get transferred again.

Multi-modal to the rescue.

Imagine if your phone company didn’t just transfer you to the number, but also sent you a text message with the business name, number, and address. That’s a multimodal conversation. You start out communicating in one channel (voice) and end up finishing the conversation or getting supplementary information via another (text).

As an example of multimodal applications, I’ve updated our Tropo Local Search demo. If you call from a mobile phone and look up a restaurant, you’ll get a text message containing the contact information of the listing you selected. Give it a try by calling (415) 894-9965 and finding coffee, pizza, or some other type of food in your neighborhood. And of course, the code is available in our documentation or on Github.