Skip to content

Instantly share code, notes, and snippets.

@devth
Created December 13, 2009 01:59
Show Gist options
  • Save devth/255206 to your computer and use it in GitHub Desktop.
Save devth/255206 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
require 'tempfile'
get '/audio' do
text = params['text']
temp_file = Tempfile.new 'mp3'
# generate mp3 to temp file
system("echo \"#{text.to_s}\" | text2wave | /opt/local/bin/lame - - > #{temp_file.path}")
# output it
headers 'Content-Type' => 'audio/mp3'
send_file temp_file.path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment