class DuoSplitter::Services::Support::BaseConcatenate

Attributes

commands[R]
context[R]

Public Class Methods

new(context:) click to toggle source
# File lib/duo_splitter/services/support/base_concatenate.rb, line 9
def initialize(context:)
  @context = context

  raise Error, "temp_dir isn't set" unless @context.temp_dir

  @commands = build_commands
end

Public Instance Methods

run() click to toggle source
# File lib/duo_splitter/services/support/base_concatenate.rb, line 17
def run
  return if @commands.empty?

  BatchProcessor.new(message: 'concatenating...', show_progress: @context.show_progress).run(@commands)
end

Private Instance Methods

build_commands() click to toggle source
# File lib/duo_splitter/services/support/base_concatenate.rb, line 25
def build_commands
  sentences.map do |sentence|
    output_path = @context.temp_dir.join(sentence.output_basename(prefix_section_number: @context.prefix_section_number, concatenated: true, ext: 'wav'))

    sentence.source_audio_path = output_path

    command = [@context.sox_path]
    command += source_paths(sentence)
    command += [output_path.to_s]

    command
  end
end
sentences() click to toggle source
# File lib/duo_splitter/services/support/base_concatenate.rb, line 39
def sentences
  raise Error, '#sentences must be defined in sub classes'
end
source_paths(_sentence) click to toggle source
# File lib/duo_splitter/services/support/base_concatenate.rb, line 43
def source_paths(_sentence)
  raise Error, '#source_paths must be defined in sub classes'
end