Posts Tagged ‘PHP’

Up in the Air with Tropo and ScraperWiki

Tuesday, December 20th, 2011

ScraperWiki is a powerful cloud-based service that lets you scrape data from online documents and websites.

When you write a scraper – a script to pull information from a web resource and then parse out the bits you want – it will execute inside the ScraperWiki environment.

SMS flight information

You can store the data that is scraped inside a data store and then access the data from outside the ScraperWiki environment using their API. Scrapers can be written in one of several different languages – Ruby, PHP and Python.

ScraperWiki and Tropo operate in a very similar way. The Tropo scripting environment allows you to write scripts in one of several different languages, including Ruby, PHP and Python (Groovy and JavaScript are also supported).

Your script executes inside the Tropo environment, which means you can make direct connections to external resources – like the ScraperWiki API – from within your executing script. There is no need for extra HTTP overhead, and the additional step of posting to a back end server to connect to other APIs or resources.

In the following screencast, I demonstrate how to use Tropo and ScraperWiki to quickly and easily build an airport information system for the Philadelphia International Airport.

All of the code for this example can be found here. If you’d like to view the actual scraper I wrote on ScraperWiki, you can find it here.

This is still a work in progress – I’d like to run this script multiple times per day (ideally, maybe once an hour) to get updates to flight information and ensure that the app has the most up to date flight status. The voice dialog could also use a little tweaking, and I’d like to offer the option of repeating the information.

But even with these refinements aside, it is evident how combining these two powerful cloud resources can generate a pretty useful application in a very short time.

Tropo and ScraperWiki are a powerful combination. Happy flying!

Tropo SMS Wolfram Alpha Mashup

Tuesday, December 13th, 2011

Tim Strimple joined us at the LA Holiday Hackathon to get in on the competition of building Tropo applications for prizes and won a $50 Tropo Production credit for his Tropo SMS and Wolfram Alpha mashup!

You can ask the application virtually any question via SMS using the following phone number 661-206-2681 and it responds to your inquiry via SMS using Wolfram Alpha’s search results. Here’s a video of Tim demonstrating his application in action!

Here’s the code behind Tim’s Tropo SMS Wolfram Alpha mashup! It’s written in PHP and uses the Tropo Scripting API.

<?php  

function CheckForShortcut($request)
{
    if(stripos($request, "siri") !== false)
    {
        return "I don't like to talk about her.";
    }

    if(stripos($request, "remind") !== false)
    {
        return "I am not your personal assistant.";
    }

    if(stripos($request, "tropo") !== false)
    {
        return "Tropo is great, I love it!";
    }

	return false;
}

function ParseResponse($response)
{	
	//	Replace with real XML parsing
	$min = strpos($response, "</plaintext>");    
	$startPos = strpos($response, "<plaintext>", $min) + 11;
    $endPos = strpos($response, "</plaintext>", $startPos);
	$length =  $endPos - $startPos;

	if($min > 0)
	{
		return substr($response, $startPos, $length);	
	}
	else
	{
		return "Go ask Siri...";
	}
}

function GetResults($request)
{
    $shortcut = CheckForShortcut($request);

    if($shortcut)
    {
        return $shortcut;
    }

    $request = str_replace (" ", "%20",$request);
	$wolframApiKey = "XXXXXX-XXXXXXXXXX";
    $url = "http://api.wolframalpha.com/v2/query?appid=" . $wolframApiKey . "&input=" . $request;
    $response = file_get_contents($url);

	return ParseResponse($response);
}

if($currentCall->channel == "TEXT")
{
    $result = GetResults($currentCall->initialText);
    say($result);
}
else
{
    say("I do not support voice currently. Try sending me a text message instead.");
}
?>

Happy Hacking!

Tropo + Ushahidi = Awesome

Friday, December 9th, 2011

Ushahidi is a platform for crowdsourcing information. Members of the public submit reports that are geo-located and then put on a map. The platform is used in disaster relief, election monitoring and just about any other situation where people need to learn things from one another quickly and concisely. Out of the box, Ushahidi allows people to submit reports via the web, mobile applications, Twitter, Facebook with support for a few SMS APIs as well.

We have created an easy-to-use application that lets people use Tropo to input data into Ushahidi via SMS. We’ve put the code up on Github and you’re welcome to submit pull requests if you find bugs or add features.

To use the code, you don’t have to install anything on Ushahidi. Here are the steps:

  1. In Ushahidi, create a user with “Admin” privileges.
  2. check out the code from Github
  3. edit the configuration lines at the top with your Ushahidi credentials and URL
  4. create a new Scripting API Application on Tropo.com.
  5. Once your Tropo app is created, you can add an SMS-enabled number (US and Canada currently) and optionally configure it to talk on any IM networks or Twitter.

Now, when you send a message to any of your configured numbers the application will attempt to geo-locate the message based on its contents. The app then submits a report via the Ushahidi API in an unverified state. Admins of the site can then verify the reports and publish them to the web.

In our example here, we simulated a flood in Milwaukee. The instance pulls in feeds from local media and disaster response community, accepts reports via the web and accepts reports from a Tropo app I created. We sent a message to the number configured in the app with the following content:

 

Columbia St. Mary’s Hospital Milwaukee WI is flooded. Power is out.

This was submitted to Ushahidi in an unverified state. The reviewer then added text to flush out the report based on other incoming data and then published the report:

Columbia hospital has been without power for the past 16 hours. Two of the three emergency diesel generators are operating normally. Generator number 2 is scheduled to be functional within the next 6 hours. Fuel supplies are at nominal levels with an estimated 48 hours remaining. Inundation levels are currently low but may begin rising at high tide.

This sort of crowdsourced data, gathered at the source, is valuable for many reasons. It gets the word to responders and the public more quickly so that people can act appropriately (e.g. by not going to that hospital, go to another one.) First responders become aware of the weight of a problem when more people report the same thing or when the first report comes in of a very big event.

Watervoices.ca, developed this past weekend at RHoK, will be going live with this application soon and we hope to see others using it to help the world soon. Over time, we will be adding support for Voice, PhoneGap within Ushahidi and many other features.

The People’s Skype for the #Occupy Movement

Monday, December 5th, 2011

This is a guest blog post by Jonathan Baldwin showcasing an application that he wrote using Tropo called The People’s Skype. It’s phone-powered, distributed voice and voting system for the #Occupy Movement!

As the Occupy Wall Street movement grew in popularity at Zucotti Park in NYC, and other occupations in North America, Jonathan noticed a problem with the primary method occupiers used to communicate in large groups. The People’s Mic, a method of augmenting a speaker’s voice by having listeners repeat their words, didn’t scale up when huge numbers of people attended rallies and General Assemblies. In these cases, the audience had to repeat the speaker’s words multiple times before it reached the far edges of the crowd – it became gradually harder to understand the original speaker’s words the further you are from the inner circle.

Motivated by this, Jonathan was determined to find a simple solution that anyone had access to. There were similar talks amongst the OWS Tech groups about ways to solve this problem, but those ideas never panned out (they included handheld radios and VoIP systems). He also wanted to address another problem of General Assemblies – hand signals are used to communicate consensus with ideas. In a massive crowd, it is hard to express opinion through visual cues, so he wanted to integrate this problem into a one package solution.

Thus, Jonathan created a one-way conference call solution, called The People’s Skype, through the Tropo phone system. Using PHP, MongoDB and Tropo, he created a simple interface that anyone with any kind of phone, no matter how old, could dial in and create a unique mic with. Upon mic creation, the speaker is given a 4 digit PIN to distribute to others that want to listen in (by holding up a sign or word of mouth). Anyone can call to the original number and listen by typing the unique PIN. Only the speaker is able to talk, while listeners can vote on issues by using their dial-tone, phone keypad (1 for Yes, 0 for No, etc.).

As the Tropo conference call system is able to support hundreds of people, audience members can either turn their speakerphones on to create a distributed PA system, or listen directly on their handsets. Due to the applications flexibility, it could potentially help fragmented occupiers communicate across police barriers or kettled areas.

Try out The People’s Skype yourself: http://www.peoplesskype.org! You can also download a copy of Jonathan’s source code from Github.

LA .NET Hackathon 2011

Monday, December 5th, 2011

Tropo is partnering with the LA .NET Developers Group and Outlook Amusements to sponsor this weekend’s LA (Burbank) Hackathon at Outlook Amusements on Saturday, December 10, 2011 from 9:00 AM to 6:30 PM (PT).

Here’s the address: Outlook Amusements 2900 W. Alameda Ave suite 400 Burbank, CA 91505

The theme of the LA Hackathon is “Build Voice/SMS apps for Holidays”! Here are a few ideas to get you thinking:

  • Santa Caller (similar to http://santacall.us) – Build a website that allows a parent to schedule a call to their kids from Santa. Have Santa ask the kid what they would like for Christmas and then email the parents their kid’s recorded message and/or transcribe the message for the email.
  • Santa Tag (similar to http://www.bloggingbistro.com/jc-penney-comes-up-with-a-new-use-for-qr-codes-video/) – Build a website that calls someone to record a message then associates the message with a QR code that plays when scanned.
  • Holiday Greetings Hotline – Build a holiday greetings hot line where user can leave a voice message that will be transcribed into text and posted to “Holiday Greetings” twitter account.

Even though this event is sponsored by the .NET Developers Group, we will be supporting all development languages and will have Tropo expertise onsite in .NET, PHP, Ruby/Rails, and Javascript, and Node.JS!

Register today!

Customer Spotlight: flockNote

Friday, December 2nd, 2011

We are excited to feature flockNote on this week’s Tropo Customer Spotlight! Today I sat down with Matthew Warner, the Founder of flockNote, and Jeff Geerling, their CTO, to discuss their business and learn more about how they are using Tropo for their Voice and SMS services.

What is flockNote?

  • flockNote is a custom registration and communication tool that takes care of your bulk emailing, text messaging, phone calling, social media and more – all from one place.
  • flockNote is made specifically for Catholic parishes, dioceses and organizations who want to connect with their members using the most effective communication tools of today.
  • It’s simple, friendly and effective. And it gives your leadership team a powerful way to organize and manage all of your communications across your many ministries.

flockNote uses PHP, Drupal, and the Tropo Scripting API to deliver Voice and SMS services to parishioners. They even use one of Tropo’s SMS short codes (84576) to deliver a very high volume of SMS messages on-demand as needed by churches.

To learn more about flockNote, visit their website at http://flocknote.com!

Keeping it Realtime with Tropo and Pusher

Friday, November 18th, 2011

We’ve done lots of examples on this blog of building realtime apps with Tropo.

Tropo is so conducive to building realtime apps with telephone components that you can pair it with almost any technology stack and add some extra hotness. Node.js, Redis, XMPP

The list gets longer today with the addition of Pusher – a hosted API for building WebSocket-based realtime apps. (Worth noting, too, that Pusher was just recognized as the Best Tool for Startups at the the European Technology Awards.)

the screencast below demonstrates a simple but powerful application built with Tropo’s WebAPI, the Git-based deployment platform Orchestra and Pusher.

The code for this demo application can, of course, be obtained via GitHub.

What makes this kind of app extra special on the Tropo platform is our international support (we have DIDs in 41 countries) and our unmatched support for TTS and ASR (we support 24 different languages).

Any developer, anywhere can create powerful realtime web apps that treat telephones as “first class citizens” with Tropo.

Keep it realtime with Tropo and Pusher.

My Voice is My Password. Verify Me.

Tuesday, August 23rd, 2011

I remember watching the movie Sneakers (probably 20 times) and would always rewind the part where they could unlock doors with their voice.

The technology, known as voice print identification or voice bio authorization, was demonstrated by the geek Werner Brandes when he utters the words, “My voice is my password. Verify me”, to gain entry to his high-tech office.

This has always sounded uber, geeky, cool to me and it’s been on my list of hacks to try out on Tropo but it looks like someone beat me to it!

The guys over at Disruptive Technologies recently wrote a blog post about Voice Biometrics with VoiceVault and Tropo!  To simplify using the VoiceVault API, Disruptive Technologies created a PHP library that can be used with Tropo for both the enrollment and the verification of voices prints. The library is available on Github as part of their sample WordPress Plugin.

Their sample WordPress Plugin was developed to show you how voice biometrics can be used in real life. You can add it to any WordPress site to enhance the user Signup and Password Reset functionality with voice biometrics and Tropo!

If you want to checkout how the plugin works, first browse to this Sign Up Page and sign up for an account. You will receive a phone call asking you, a couple of times, to speak a 4 digit code, this is used to enroll your voice. After enrolling your voice you can call+1(818) 533-9824  to receive a new temporary password to login to WordPress. Make sure to call from the phone number you registered when you signed up for the WordPress account!

Image the communications apps that you could build using this technology!  The future is now so what are you waiting for – add voice bio metrics to your apps today using Tropo and VoiceVault thanks to Disruptive Technologies!

Speech Enabling Open311

Tuesday, August 9th, 2011

Since SpeechTEK is this week, I thought it was a good time to update a post I did several months ago on using speech recognition to capture a street address.

There are lots of reasons why you might want to collect a caller’s address over the phone.

In open government circles, there has been a lot of interest lately in using automated IVR systems to help gather non-emergency service requests for municipalities. This makes a lot of sense – many municipalities enable non-emergency service reporting through the use of a designated abbreviated dialing number – 3-1-1 – so there is a long history of reporting these issues using the telephone.

Address collection is used quite often in IVR systems, but typically relies on expensive proprietary or “black box” components that might not be suitable for all use cases. This is particularly true for municipalities and local governments who are under financial pressure and who need to do more with less.

In this post, I’ll show how to build a sophisticated address collection system that can be used for almost any city or town, large or small. All of the code for this example is on GitHub (and under active development) and many of the components I will use are free or open source.

Here is a screen cast demonstrating the system running on the Tropo platform.

How it works

The application demonstrated here relies on three primary ingredients:

  • A data source with all of the street names in a city (in this case, I used the San Francisco Basemap Street Centerlines file from DataSF.org)
  • A database that can store the data on street names and zip codes, and which can be queried to render a speech grammar. In this instance, I use CouchDB.
  • A telephony platform that supports speech recognition – in this case, Tropo.

The application is structured to ask the caller for a zip code – obtaining a zip code will help us constrain the number of choices in our speech grammar and help ensure a better recognition.

The application then builds an SRGS grammar in XML format using CouchDB’s view and list functions. This grammar contains a list of all of the streets in a particular zip code and allows a caller to add additional details, like house number and street direction (if applicable).

In the event that a successful match can’t be made (this is inevitable in some small percentage of calls), we ask the caller to say their full address and make a recording.

This recording can be transcribed after the call has ended to gather the caller’s address – this might be a manual step, or it could be automated using functionality provided by Tropo.

Building for the cloud

The example shown here is built to run on the Tropo cloud communication platform, and uses a cloud-based instance of CouchDB.

This same basic approach could be replicated with a more conventional architecture, and could also use a standard relational database (as I did in my previous post on this subject).

But using cloud-based components has a number of advantages that might be attractive to smaller governments that want to employ this approach, or even larger governments that face fiscal constraints or challenges.

Using a cloud-based platform like Tropo makes deployment and scaling easy. It also means that you get access to the latest and greatest technology to support the open specification for speech recognition grammars. The folks that work at Voxeo (the company behind Tropo) help write these standards.

Using CouchDB has a number of advantages too. Populating a CouchDB instance with street data is extremely easy with tools like shp2geocouch by Max Ogden. In addition, it’s actually pretty straightforward to write view and list functions to generate a speech grammar – after all it’s just JavaScript.

If you found this post and screen cast useful, head on over to the GitHub repo for this solution and sign on as a watcher – I’m going to be actively developing this with the goal of deploying it for a municipality in the near future.

Stay tuned!

Tropo Speaks your Language – 24 in all

Friday, July 1st, 2011

Tropo’s international support is one of the features people love best about us. Numbers in 41 countries, SMS delivery worldwide, and text to speech and speech recognition in 9 languages.

Wait, only nine languages? Surely we can do better.

Tropo can now speak and understand 17 new languages (for a total of 24) with speech recognition and text to speech in both male and female voices in Catalan, Danish, Finnish, Canadian French, Galacian (female only), Greek, Mandarin Chinese (female text to speech only), Norwegian (no speech recognition), Russian, Argentine Spanish (male only), Chilean Spanish, (female only), Portuguese, Brazilan Portuguese, Swedish, and Valencian.

We’ve added 14 new voices to existing languages. US English, UK English, French, Italian, Spanish, and Mexican Spanish all get new voices for you to play with.

These languages are available immediately in both our free developer accounts and production applications.

The Tropo documentation will always have a list of the current languages, voices, and recognition engines and is the best place to go for up-to-date information, but for convenience, here’s a list of all the languages and voices that are supported today.

Language Recognizer Female voice Male Voice
English (US) en-us (default) Allison (default), Susan, Vanessa Dave, Steven, Victor
English (UK) en-gb Elizabeth, Kate Simon
Catalan ca-es Montserrat Jordi
Danish da-dk Frida Magnus
Dutch nl-nl Saskia Willem
Finnish fi-fi Milla Mikko
French fr-fr Florence, Juliette Bernard
French (Canadian) fr-ca Charlotte Olivier
Galacian gl-es Carmela
German de-de Katrin Stefan
Greek el-gr Afroditi Nikos
Italian it-it Giulia, Paola, Silvana, Valentina Luca, Marcello, Matteo, Roberto
Mandarin Chinese Linlin, Lisheng
Norwegian Vilde Henrik
Polish pl-pl Zosia Krzysztof
Russian ru-ru Olga Dmitri
Spanish (Castilian) es-es Carmen, Leonor Jorge, Juan
Spanish (Argentine) es-ar Diego
Spanish (Chilean) es-cl Francisca
Spanish (Mexican) es-mx Soledad, Ximena, Esperanza Carlos
Portuguese pt-pt Amalia Eusebio
Portuguese (Brazilian) pt-br Fernanda, Gabriela Felipe
Swedish sv-se Annika Sven
Valencian x-va Empar

One thing to note is that if you use PHP, it does not handle unicode very well. This can lead to problems when using some voices in PHP in our scripting API, and is especially problematic when using multibyte languages like Chinese. We’re working with Quercus, our PHP engine, to try and improve the unicode support.

Tropo is only two and a half years old and can speak twenty-four languages. That’s one precocious toddler.