Sha256: f0bb6f838623fca949e2310d751750c3818530933d3099828eec67ac50753940
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
#!/usr/bin/env ruby $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib') require 'rest_client' require 'mime/types' require 'tempfile' filename = ARGV[1] basename = File.basename(filename) types = MIME::Types.type_for(filename) valido = false for i in types if i.content_type.include? "wav" or i.content_type.include? "x-wav" valido = true end end t = nil if !valido t = Tempfile.new(basename) puts "convirtiendo a wav antes de subir" `rm -f "#{t.path}"` `ffmpeg -i "#{filename}" -vn -acodec pcm_s16le -ar 16000 -ac 1 -f wav "#{t.path}"` filename = t.path end file = File.new(ARGV[1]) public = false if ARGV.size >= 3 public = ARGV[2] end puts "uploading..." begin RestClient.post('http://cluster.metaforas.cl/audios', "audio[audio_original]" => File.new(filename), :api => ARGV[0], "audio[public]" => public, "audio[txt]" => ARGV[3] ) rescue RestClient.post('http://cluster.metaforas.cl:8000/audios', "audio[audio_original]" => File.new(filename), :api => ARGV[0], "audio[public]" => public, "audio[txt]" => ARGV[3] ) end if !valido t.close `rm -f "#{t.path}"` end puts "ready"
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fonemas-0.4.13 | bin/audioupload |