Skip to content

Instantly share code, notes, and snippets.

@zlu
zlu / x
Created January 6, 2009 01:11
Ubiquity command for searching rails APIs
CmdUtils.CreateCommand(
{
name: "rails",
takes: {"method": noun_arb_text},
icon: "http://rubyonrails.org/images/rails.png",
homepage: "",
author: {name: "Zhao Lu", email: "zhao.lu.us@gmail.com"},
license: "MPL,GPL",
description: "Search rails documentation",
help: "Type a rails class or method",
##Flowroute sip.conf
register => uname:secret@sip.flowroute.com
[flowroute] ;keep this lowercase, do not change format
type=friend
secret=
username=
host=sip.flowroute.com
dtmfmode=rfc2833
context=flowroute ;change to 'ext-did' or 'from-trunk' for asterisk@home
#Method to create files themselves, takes the texts, creates the file and returns the filename
def surveys_create_file(text)
case engine
#Cepstral speech engine, see http://www.cepstral.com, as it requires a license
when "cepstral"
filename = '/var/lib/asterisk/sounds' + new_guid + ".wav"
system("swift -o #{filename} -p audio/channels=1,audio/sampling-rate=8000 '#{text}'")
#Festival OSS speech engine
#on CentOS v5.0+ simply do a yum install festival
Installing AMR libraries:
Grab the AMR Codec Libraries (The FFmpeg documentation has a section about installing AMR):
e.g. amrnb-6.1.0.4.tar.bz2 and amrwb-7.0.0.1.tar.bz2
Decompress sources:
bunzip2 amrnb-6.1.0.4.tar.bz2
tar xvf amrnb-6.1.0.4.tar
Change directory:
cd amrnb-6.1.0.4
Configure and install:
./configure
#Sinatra server
require 'rubygems'
require 'sinatra'
post '/upload' do
filename = "./uploaded/" + Time.now.to_i.to_s + ".gsm"
FileUtils.mv params[:data][:tempfile].path, filename
"Received #{File.size filename} bytes and saved as #{filename} for user #{params[:user_id]}"
end
require 'rubygems'
require 'open-uri'
require 'curb'
api_access_key = "xxx"
url = "http://voicemail.alpha.orange-api.net/voicemail/updateAnnouncement.xml"
c = Curl::Easy.new url
c.multipart_form_post = true
c.http_post Curl::PostField.file('sound', './tt-monkeys.wav'), Curl::PostField.content('id', "#{api_access_key}")
Installing AMR libraries:
Grab the AMR Codec Libraries (The FFmpeg documentation has a section about installing AMR):
e.g. amrnb-6.1.0.4.tar.bz2 and amrwb-7.0.0.1.tar.bz2
Decompress sources:
bunzip2 amrnb-6.1.0.4.tar.bz2
tar xvf amrnb-6.1.0.4.tar
Change directory:
cd amrnb-6.1.0.4
Configure and install:
./configure
answer
wait 1000
result = record("Please leave your message at the beep",{'beep'=>true, :silenceTimeout=> 8, :maxTime=>30,:timeout=>5.03456789})
log "recorded " + result.recordURI.to_s
require 'open-uri'
uri = URI.encode(result.recordURI)
opened = open(uri, :http_basic_authentication => ["", ""])
read = opened.read
log "downloaded"
#tropo example, playing twitter friends timeline
require 'json'
require 'net/http'
answer
say 'hello, welcome to your twitter status'
options = {
:choices => 'asha(1, asha), georges(2, georges), jason(3, jason), mark(4, mark), zhao(5, zhao)',
answer
wait 1000
result = record("Please leave your message at the beep",{'beep'=>true, :silenceTimeout=> 8, :maxTime=>30,:timeout=>5.03456789})
log "recorded " + result.recordURI.to_s
require 'open-uri'
uri = URI.encode(result.recordURI)
opened = open(uri, :http_basic_authentication => ["", ""])
read = opened.read
log "downloaded"