def split_by_silence(options={})
      above_period_duration = options[:above_period_duration] || "0.5"
      above_period_threshold = options[:above_period_threshold] || "0.05"
      below_period_duration = options[:below_period_duration] || "1.0"
      below_period_threshold = options[:below_period_threshold] || "0.02"

      effect = "silence 1 #{above_period_duration} #{above_period_threshold}% 1 #{below_period_duration} #{below_period_threshold}% : newfile : restart"
      input_format = options[:input_format] ? options[:input_format] : "mp3"
      output_format = options[:output_format]
      output_filename = options[:output_filename] || "out"
      # Default to wav
      dir = Dir.mktmpdir
      format = output_format ? ".#{output_format}" : ".wav"
      dst = "#{dir}/#{output_filename}#{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 => dst)
      rescue => e
        raise AudioHeroError, "There was an error splitting #{@basename}"
      end
      garbage_collect(@file) if options[:gc] == "true"

      Dir["#{dir}/**/*#{format}"]
    end
def split_by_silence(options={})
      above_period_duration = options[:above_period_duration] || "0.5"
      above_period_threshold = options[:above_period_threshold] || "0.05"
      below_period_duration = options[:below_period_duration] || "1.0"
      below_period_threshold = options[:below_period_threshold] || "0.02"

      effect = "silence 1 #{above_period_duration} #{above_period_threshold}% 1 #{below_period_duration} #{below_period_threshold}% : newfile : restart"
      input_format = options[:input_format] ? options[:input_format] : "mp3"
      output_format = options[:output_format]
      output_filename = options[:output_filename] || "out"
      # Default to wav
      dir = Dir.mktmpdir
      format = output_format ? ".#{output_format}" : ".wav"
      dst = "#{dir}/#{output_filename}#{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 => dst)
      rescue => e
        raise AudioHeroError, "There was an error splitting #{@basename}"
      end
      garbage_collect(@file) if options[:gc] == "true"

      Dir["#{dir}/**/*#{format}"]
    end
Usage: AudioHero::Sox.new(file).split_by_silence({input_format: "wav"})
 Returns an array of the full path of the splitted files, can split two input files at one go using {file2: file} option.
 Remember its good practice to remove the temp directory after use.
 FileUtils.remove_entry tempdir