Posts tagged "ruby"

Processing Recorded Audio Files

We have received several inquiries lately on how to receive and process audio files recorded on Teleku using the phoneml <record> audio tag like in the following example:

<phoneml>
<speak>please record a message</speak>
<record>http://web1.tunnlr.com:yourkey/upload/uploadTeleku</record>
</phoneml>

I was able to build a simple Rails application today that allows you to upload a file from the browser as well as receive a recorded file from Teleku.  The source code is available at: http://github.com/chrismatthieu/teleku-record-sample

This code was heavily inspired by a blog post located at http://www.tutorialspoint.com/ruby-on-rails/rails-file-uploading.htm and you must comment out protect_from_forgery line in application controller to avoid the token error caused by the data coming from another application (Teleku).  You could probably just override/disable forgery protection on this one controller or action.

I am using tunnlr to test it with extension 388 (http://teleku.com/extensions/388) over SIP using my Blink SIP client for the Mac.  The data gets stored in the public/data directory but you could redirect the files to either your own database or S3.

I hope this example helps!

Team Teleku

1

Teleku Architecture

Many people are interested in how Teleku’s cloud communications platform is built so we’ll explain.  There are two parts to Teleku’s cloud services (Web and Voice/SMS):

Our Web Architecture:

Both the Teleku.com web site and its RESTful phone web service APIs are built 100% on Ruby on Rails.  Our Web application is hosted on Heroku which is essentially Amazon EC2 cloud hosting for Ruby/Rails applications.  The website and its APIs are designed to scale as demand fluctuates. We are using NimbleNodes to monitor our Heroku Dynos to help us scale automagically with demand.

Our Voice/SMS Architecture consists of two platforms (Ninja and Samurai Warrior).  Ninja is a stack of open source telephony technologies running directly in the Amazon EC2 cloud.  The Ninja stack consists of Asterisk, OpenVXI, VoiceGlue, Flite TTS, and a little custom Sinatra/Ruby glue written by us. 

Ninja relies entirely on SIP-based communications to handle its inbound and outbound communications. We have recently integrated GoogleVoice and Gizmo into our platform for both voice and SMS functionality.  More details about this integration can be found here.  You can also route any PSTN phone number (local or toll free) into Teleku using a SIP Gateway Service Provider.  SMS services are provided via direct carrier SMTP traffic and, in GoogleVoice’s instance, RESTful Google APIs.  Outbound calls are also supported on the Ninja platform via SIP.  SIP Gateways can translate SIP addresses to outbound PSTN phone numbers for as low as $.01 per minute via Gizmo and others.

We offer upgraded telephony hosting services under our Samurai Warrior label through a number of VoiceXML Gateway hosting providers including: Voxeo, Plum Voice, I6NET, XO Communications, TellMe, Genesys Lab, and others.  These services offer improved text-to-speech and speech recognition capabilities as well as other services such as: Skype integration, SLAs, and managed phone numbers. 

Since our Samurai Warrior offering basically translates Teleku PhoneML to VoiceXML, enterprise customers can also take advantage of this service to run Teleku-based phone applications with their on-premise VoiceXML Gateway infrastructures.  Our cloud communications service allows calls to originate and/or terminate on the enterprise’s own VoiceXML Gateway platform.  Only our PhoneML web service translations to VoiceXML occur on our SaaS cloud platform.  All call traffic, web applications, VoiceXML hosting services, and databases can reside behind a customer’s firewall on-site.   We believe that our solution uniquely caters to enterprise customers by allowing them to leverage their existing VoiceXML infrastructure investments, security of data on-site, and engaging their Web developers in building and maintaining enterprise phone application portfolios.

Teleku allows enterprises to take a baby-step into cloud services without the perceived risks that enterprises typically associate with the cloud. 

4

High/Low Game (Ruby)

Here is an example of a Teleku PhoneML voice application written in Ruby and running on Sinatra.  You can access this application on Heroku at http://highlow.heroku.com.

require ‘rubygems’
require ‘sinatra’
require ‘builder’

get ‘/’ do
‘HighLow is a <a href=”teleku.com”>Teleku Voice Application</a><br>’
‘curl —data-urlencode “caller=test” http://highlow.heroku.com
end

post ‘/’ do
deal = 1 + rand(10)
builder do |xml|
xml.instruct!
xml.phoneml do
xml.speak “welcome to the game of high low”
xml.speak “the dealer randomly selected ” + deal.to_s
xml.speak “will his next number be higher or lower? press 1 or say higher or press 2 or say lower”
xml.input “http://highlow.heroku.com/guess/” + deal.to_s, “options”=>”1,2,higher,lower”
end
end
end

post ‘/guess/:deal’ do
newdeal = 1 + rand(10)
guess = params[:CallerInput]
if guess == ‘1’ or guess == ‘higher’
if newdeal > params[:deal].to_i
gamestatus = “winner”
else
gamestatus = “loser”
end
end 

if guess == ‘2’ or guess == ‘lower’
if newdeal < params[:deal].to_i 
gamestatus = “winner”
else
gamestatus = “loser”
end
end 

builder do |xml|
xml.instruct!
xml.phoneml do
xml.speak “the dealer randomly selected ” + newdeal.to_s
xml.speak “you are a ” + gamestatus    
xml.speak “will his next number be higher or lower? press 1 or say higher or press 2 or say lower”
xml.input “http://highlow.heroku.com/guess/” + newdeal.to_s, “options”=>”1,2,higher,lower”
end
end
end