Sha256: cfc766c58e90c188941e14f23426074737ad714799aa2bb8533295eb3dc3aa46

Contents?: true

Size: 957 Bytes

Versions: 1

Compression:

Stored size: 957 Bytes

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 = Tempfile.new(basename)

if !valido
    puts "convirtiendo a wav antes de subir"
    `ffmpeg -i "#{filename}" -vn -acodec pcm_s16le -ar 16000 -ac 1 -f wav "#{t.path}"`
    filename = t.path
end


file = File.new(ARGV[1])

puts "uploading..."

begin
    RestClient.post('http://cluster.metaforas.cl/audios',
      "audio[audio_original]" => File.new(filename),
      :api => ARGV[0])
rescue
    RestClient.post('http://cluster.metaforas.cl:8000/audios',
          "audio[audio_original]" => File.new(filename),
          :api => ARGV[0])

end


t.close


puts "ready"

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fonemas-0.4.10 bin/audioupload