def remove_silence(options={})
      above_period_duration = options[:above_period_duration] || "0.1"
      above_period_threshold = options[:above_period_threshold] || "0.03"
      below_period_duration = options[:below_period_duration] || "0.1"
      below_period_threshold = options[:below_period_threshold] || "0.03"
      effect = "silence 1 #{above_period_duration} #{above_period_threshold}% -1 #{below_period_threshold} #{below_period_threshold}%"
      input_format = options[:input_format] ? options[:input_format] : "mp3"
      output_format = options[:output_format] ? options[:output_format] : "wav" # Default to wav

      dst = Tempfile.new(["out", ".#{output_format}"])
      begin
        parameters = []
        parameters << "-t #{input_format}"
        parameters << ":source"
        parameters << ":dest"
        parameters << effect
        parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
        success = Cocaine::CommandLine.new("sox", parameters).run(:source => get_path(@file), :dest => get_path(dst))
      rescue => e
        raise AudioHeroError, "There was an error converting #{@basename} to #{output_format}"
      end
      garbage_collect(@file) if options[:gc] == "true"
      dst
    end
def remove_silence(options={})
      above_period_duration = options[:above_period_duration] || "0.1"
      above_period_threshold = options[:above_period_threshold] || "0.03"
      below_period_duration = options[:below_period_duration] || "0.1"
      below_period_threshold = options[:below_period_threshold] || "0.03"
      effect = "silence 1 #{above_period_duration} #{above_period_threshold}% -1 #{below_period_threshold} #{below_period_threshold}%"
      input_format = options[:input_format] ? options[:input_format] : "mp3"
      output_format = options[:output_format] ? options[:output_format] : "wav" # Default to wav

      dst = Tempfile.new(["out", ".#{output_format}"])
      begin
        parameters = []
        parameters << "-t #{input_format}"
        parameters << ":source"
        parameters << ":dest"
        parameters << effect
        parameters = parameters.flatten.compact.join(" ").strip.squeeze(" ")
        success = Cocaine::CommandLine.new("sox", parameters).run(:source => get_path(@file), :dest => get_path(dst))
      rescue => e
        raise AudioHeroError, "There was an error converting #{@basename} to #{output_format}"
      end
      garbage_collect(@file) if options[:gc] == "true"
      dst
    end
Usage: file = AudioHero::Sox.new(file).remove_silence