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
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/diarize/segmentation.rb', line 38 def self.from_clusters(audio, clusters) segmentation = [] clusters.each do |speaker_id| cluster = clusters.get_cluster(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
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/diarize/segmentation.rb', line 23 def self.from_seg_file(audio, seg_file) segmentation = [] File.open(seg_file).lines.each 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 |