Quickly: with this script and a free k7.net account you can post voicemail messages to your twitter account.
On Saturday I gave a quick demo at barcampdc on a ruby script I wrote called voicemail2twitter.rb.
This was the barebones 5 minute slideshow:
And here is the code:
#! /usr/bin/env ruby
require 'rubygems'
require_gem 'actionmailer'
require 'twitter'
ActionMailer::Base.smtp_settings = {
:address => 'localhost',
:port => 25,
:domain=> 'slapcast.com',
}
ActionMailer::Base.delivery_method = :smtp
class Mailman < ActionMailer::Base
def receive(email)
if email.has_attachments?
for attachment in email.attachments
base_dir = "/home/barcampdcaudio/web/"
wav_name = "#{Time.now.to_i}-#{rand(1000)}"
wav_path = "#{base_dir}#{wav_name}"
mp3_path = "#{wav_path}.mp3"
File.open(wav_path,File::CREAT|File::TRUNC|File::WRONLY,0666){ |f|
f.write(attachment.read)
}
#convert wav to mp3
system("/usr/bin/sox #{wav_path} -t wav -s -w - | /usr/local/bin/lame --resample 22 -v -q 0 -V 9 --quiet - #{mp3_path}")
system("chmod 777 #{mp3_path}") #yes, probably don't need a system call for this
mp3_url = "http://slapcast.com/m/#{wav_name}"
#post the link to twitter
Twitter::Base.new('barcampdcaudio', 'twitter_password_goes_here').update("#{mp3_url}.mp3")
end
end
end
end
Mailman.receive(STDIN.read)

