Posting Tropo Transcriptions to Google AppEngine

Now that Tropo offers transcriptions, I would like to provide another example of using cloud services to manage your transcription results. In this case we will use Google AppEngine’s (GAE) Java implementation by deploying with JRuby, leveraging a similar architecture to what we use on Tropo for hosting our scripting languages.

I have created another Sinatra application (tropo-transcriptions) that provides an HTTP REST API for receiving POSTs of transcriptions from the Tropo cloud. The same application then allows you to get those results, either by fetching all or a single transcription. The app takes advantage of Google’s BigTable on GAE, storing all of the transcriptions right in the cloud in a schemaless data store. Using the unofficial Ruby/JRuby Google library, appengine-jruby, I have already created everything you need to simply download and deploy the application. This means that it already has JRuby and all of the Ruby gems baked into the app, so you get running with minimal fuss.

The first step is to install the google-appengine gem and download the tropo-transcriptions source code (you may do a Git clone or download from Github):

TropoTranscriptionInstall

After having signed up for Google AppEngine and creating an application, then you need to make one configuration change to your application you just downloaded. Editing the file tropo-transcriptions/config.ru, make the following change to line 3:

:application => 'tropo-transcriptions'

becomes:

:application => 'your-app-name'

Then the last step is to deploy your application to Google AppEngine. To do this simply cd into your application’s directory and enter:

  appcfg.rb update .

You will be prompted for your GAE username and password and you should then see:

TropoTranscriptionDeployGAE

Thats it, you are now up and running. There are now three resources available on your new HTTP web services app:

1. POST to receive transcriptions

  http://your-app-name.appspot.com/receive_transcription

2. GET to fetch all transcriptions

  http://your-app-name.appspot.com/transcriptions

3. GET to fetch a single transcription based on GUID

  http://your-app-name.appspot.com/transcription?guid=5fad8750-7316-012c-00bd-0400580fde23

Now, you may start using your new server to store your transcription results. Simply use the first URL in the transcriptionOutURI portion of your recording request of your Tropo script:

  answer
  say 'Welcome to ruby recording test'

  event = record('Say something after the beep.',
                           { :repeat              => 0,
                             :bargein             => true,
                             :beep                => true,
                             :silenceTimeout      => 2,
                             :maxTime             => 30,
                             :timeout             => 4,
                             :recordURI           => 'http://tropo.to-a-domain.com/post_audio?filename=file123456.wav',
                             :transcriptionOutURI => 'http://your-app-name.appspot.com/receive_transcription',
                             :transcriptionID     => '123456' })

  log 'Recorded file: ' + event.recordURI
  say 'Thanks for your testing ruby on Tropo platform'
  hangup

Make a few calls and you should see this when you put the second URL above in your browser:

TranscriptionResult

There is more to come…

An App for Posting Tropo Audio Files to Amazon S3 via Heroku

At Voxeo Labs we clearly have an affinity for clouds. Now that we provide the ability to easily push recorded audio files out of the Tropo cloud, we would like to provide an example of how to receive and post these files using other great clouds.

For this example we are going to use Sinatra to create a REST web service application. This application will then be deployed to Heroku where it will receive and then push the recorded audio files from Tropo up to an Amazon S3 account.

First, Sinatra provides a simple domain specific language in Ruby for creating REST web services, or whole web sites if you choose to. In this case we are using Sinatra to write our REST API to receive and then process the audio file. Creating an HTTP resource with Sinatra is as simple as this:

  get '/pizza' do
    order params['toppings']
    # Do some more stuff
  end

To get this resource you would then put this in your web browser:

  http://www.yourhost.com/pizza?toppings=pepperoni

If we take this a step further, writing the code to receive an audio file and post to Amazon S3 is not much harder:

post '/post_audio_to_s3' do
  AWS::S3::S3Object.store(params['file_name'],
                          File.open(params['filename'][:tempfile].path),
                          AWS_CONFIG['bucket_name'])
end

In your Tropo app you may then write a script to record and send an audio file:

  answer
  say 'Welcome to the recording application'
  startCallRecording 'http://www.yourhost.com/post_audio_to_s3?file_name=myfilename.wav'
  ask 'Do you like chocolate?', { :choices => 'yes, no' }
  stopCallRecording
  hangup

Now we have our web service, but where to run it? This is where Heroku comes in. Heroku is an ‘instant Ruby platform’ that allows you to deploy an application, via Git, and have it up and running on a scalable infrastructure in minutes. Lucky for us, Heroku excels at running Sinatra apps, and they even have the AWS-S3 library built in. All you need is a Heroku account, which is free to get started with a Blossom, and you are ready to start running your web service.

Last but not least, you will need an Amazon S3 account to store your files. Thats it, you may now start moving your files through the clouds to Amazon, or use this as an example to store them wherever you choose. The full application ready to deploy locally or to Heroku is available at Github here.

Adhearsion and Voxeo join to create Voxeo Labs!

The Adhearsion team is excited to announce today the new directions Adhearsion, Tropo and Voxeo will be taking, including the launch of Voxeo Labs.

Adhearsion arose in 2006 from frustrations Jay Phillips had while writing telephony applications with Asterisk, the predominant open-source telephony platform. Inspired by the nascent Ruby on Rails web development framework, Jay began applying the same modern software development principles to an application layer than ran above Asterisk which ultimately became Adhearsion. As the Ruby and Rails spaces grew and Jay travelled the world to do consulting and speak at conferences, so grew the Adhearsion community. Today, over three years after Jay wrote the first versions of Adhearsion, the team is now two-strong with Jason Goecke having joined last year to help with the day-to-day complexities and coding associated with a consulting company and open-source project.

The Adhearsion project’s founding principle was simple: make telephony accessible and exciting. Out of this grew the desire to build a hosting company which mitigated the largest problem people having with using Adhearsion: hosting and operationalizing a telephony system after they actually write it. Thus began Adhearsion’s discussions with Voxeo.

In January 2009 Voxeo began planning a new scripting language-based platform named Tropo that had similar ambitions as Adhearsion. As the Tropo team started planning how robust frameworks like Adhearsion could work atop Tropo, the plans for a generic, ideal hosted telephony engine arose and became overwhelmingly exciting.

With the added power of the cloud-friendly Tropo engine and the robust simplicity of the open-source Adhearsion framework atop it, telephony can truly become accessible to the many people with great ideas but justified hesitation about the telephony status quo. With Voxeo Labs, Adhearsion and Voxeo will further develop Adhearsion, Tropo, and new exciting applications that utilize cutting edge web and open-source technologies.

What does this mean for the Adhearsion community?

Voxeo Labs is committed to open-source. This announcement should be seen as Adhearsion achieving a critical step to its overall success: a reliable hosting solution atop a great platform from a very trusted name in the telephony hosting business. The open-source development will remain as active as ever, if not moreso, as the new power of Tropo enables new and innovative features for the framework.

We would like to thank the community for all of their support that has allowed us to continue to take Adhearsion forward. We will continue that evolution to ensure the developer community has the tools it needs to develop compelling applications and accomplish all of their exciting telephony ambitions!

For the full press release, click here.