duo_splitter 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/README.ja.md +128 -0
  3. data/README.md +13 -11
  4. data/exe/duo_splitter +9 -3
  5. data/lib/duo_splitter.rb +39 -10
  6. data/lib/duo_splitter/batch_processor.rb +36 -0
  7. data/lib/duo_splitter/commands/base_command.rb +121 -0
  8. data/lib/duo_splitter/commands/overlapping_command.rb +37 -0
  9. data/lib/duo_splitter/commands/repeating_command.rb +38 -0
  10. data/lib/duo_splitter/commands/split_command.rb +31 -0
  11. data/lib/duo_splitter/context.rb +34 -0
  12. data/lib/duo_splitter/encoders/aac_encoder.rb +17 -0
  13. data/lib/duo_splitter/encoders/base_encoder.rb +57 -0
  14. data/lib/duo_splitter/encoders/mp3_encoder.rb +17 -0
  15. data/lib/duo_splitter/encoders/wav_encoder.rb +17 -0
  16. data/lib/duo_splitter/models/album.rb +23 -0
  17. data/lib/duo_splitter/models/section.rb +38 -0
  18. data/lib/duo_splitter/models/sentence.rb +35 -0
  19. data/lib/duo_splitter/runner.rb +43 -64
  20. data/lib/duo_splitter/services/create_overlapping_sentences.rb +19 -0
  21. data/lib/duo_splitter/services/create_repeating_sentences.rb +20 -0
  22. data/lib/duo_splitter/services/create_sentences.rb +18 -0
  23. data/lib/duo_splitter/services/support/base_concatenate.rb +46 -0
  24. data/lib/duo_splitter/services/support/create_blank_sentences.rb +40 -0
  25. data/lib/duo_splitter/services/support/encode.rb +23 -0
  26. data/lib/duo_splitter/services/support/overlapping_concatenate.rb +19 -0
  27. data/lib/duo_splitter/services/support/repeating_concatenate.rb +22 -0
  28. data/lib/duo_splitter/services/support/split_tracks.rb +42 -0
  29. data/lib/duo_splitter/temp_dir_wrapper.rb +20 -0
  30. data/lib/duo_splitter/version.rb +3 -1
  31. metadata +34 -15
  32. data/lib/duo_splitter/aac_encoder.rb +0 -13
  33. data/lib/duo_splitter/album.rb +0 -21
  34. data/lib/duo_splitter/encoder.rb +0 -71
  35. data/lib/duo_splitter/mp3_encoder.rb +0 -13
  36. data/lib/duo_splitter/section.rb +0 -30
  37. data/lib/duo_splitter/sentence.rb +0 -22
  38. data/lib/duo_splitter/wav_encoder.rb +0 -13
@@ -1,13 +0,0 @@
1
- module DuoSplitter
2
- class MP3Encoder < Encoder
3
- attr_reader :ext, :encoding_options
4
-
5
- def initialize(**)
6
- super
7
- @ext = 'mp3'
8
- @encoding_options = ['-codec:a', 'libmp3lame', '-q:a', '0']
9
- end
10
- end
11
-
12
- Encoder.register(:mp3, MP3Encoder)
13
- end
@@ -1,30 +0,0 @@
1
- module DuoSplitter
2
- class Section
3
- attr_reader :number, :sentences
4
-
5
- attr_accessor :source_path
6
-
7
- def initialize(number:)
8
- @number = number
9
- @sentences = load_sentences
10
- end
11
-
12
- private
13
-
14
- def load_sentences
15
- label_path = DATA_DIR.join('labels/%02d.txt' % number)
16
-
17
- records = label_path.readlines.map {|line| line.chomp.split(/\t/) }
18
-
19
- records.unshift(%w[0 0 0])
20
-
21
- records.each_cons(2).map do |current_record, next_record|
22
- sentence_number = current_record.last.to_i
23
- start_pos = current_record.first
24
- end_pos = next_record.first
25
-
26
- Sentence.new(number: sentence_number, start_pos: start_pos, end_pos: end_pos, section: self)
27
- end
28
- end
29
- end
30
- end
@@ -1,22 +0,0 @@
1
- module DuoSplitter
2
- class Sentence
3
- attr_reader :number, :start_pos, :end_pos, :section
4
-
5
- def initialize(number:, start_pos:, end_pos:, section:)
6
- @number = number
7
- @start_pos = start_pos
8
- @end_pos = end_pos
9
- @section = section
10
- end
11
-
12
- def intro?
13
- number.zero?
14
- end
15
-
16
- def output_name(add_section_prefix: true, ext:)
17
- name = '%03d.%s' % [number, ext]
18
- name = ('%02d-' % section.number) + name if add_section_prefix
19
- name
20
- end
21
- end
22
- end
@@ -1,13 +0,0 @@
1
- module DuoSplitter
2
- class WAVEncoder < Encoder
3
- attr_reader :ext, :encoding_options
4
-
5
- def initialize(**)
6
- super
7
- @ext = 'wav'
8
- @encoding_options = ['-codec:a', 'pcm_s16le']
9
- end
10
- end
11
-
12
- Encoder.register(:wav, WAVEncoder)
13
- end