Class: Diarize::Segmentation
- Inherits:
-
Object
- Object
- Diarize::Segmentation
- Defined in:
- lib/diarize/segmentation.rb
Class Method Summary collapse
Class Method Details
.from_clusters(audio, clusters) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/diarize/segmentation.rb', line 19 def self.from_clusters(audio, clusters) segmentation = [] clusters.map(&:to_s).each do |speaker_id| cluster = clusters.getCluster(speaker_id) gender = cluster.gender bandwidth = cluster.bandwidth cluster.each do |segment| start = segment.start_in_second duration = segment.length_in_second segmentation << Segment.new(audio, start, duration, gender, bandwidth, speaker_id) end end segmentation end |
.from_seg_file(audio, seg_file) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/diarize/segmentation.rb', line 4 def self.from_seg_file(audio, seg_file) segmentation = [] File.open(seg_file).each_line do |line| next if line.start_with? ';;' parts = line.split(' ') start = parts[2].to_i / 100.0 duration = parts[3].to_i / 100.0 gender = parts[4] bandwidth = parts[6] speaker_id = parts[7] segmentation << Segment.new(audio, start, duration, gender, bandwidth, speaker_id) end segmentation end |