class DuoSplitter::Services::Support::CreateBlankSentences
Attributes
commands[R]
Public Class Methods
new(context:)
click to toggle source
# File lib/duo_splitter/services/support/create_blank_sentences.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/create_blank_sentences.rb, line 17 def run return if @commands.empty? BatchProcessor.new(message: 'creating blank sentences...', show_progress: @context.show_progress).run(@commands) end
Private Instance Methods
build_commands()
click to toggle source
# File lib/duo_splitter/services/support/create_blank_sentences.rb, line 25 def build_commands sentences = @context.album.sentences(intro: @context.output_intro).select(&:audio_path) sentences.map do |sentence| output_path = @context.temp_dir.join(sentence.output_basename(prefix_section_number: @context.prefix_section_number, blank: true, ext: 'wav')) sentence.blank_audio_path = output_path command = [@context.sox_path] command += %w[-n -c 2 -e signed-integer -r 44100 -b 16] command += [output_path.to_s, 'trim', '0.0', sentence.duration.to_s] command end end