class Diarize::Segment

Attributes

bandwidth[R]
duration[R]
speaker_gender[R]
speaker_id[R]
start[R]

Public Class Methods

new(audio, start, duration, speaker_gender, bandwidth, speaker_id) click to toggle source
# File lib/diarize/segment.rb, line 7
def initialize(audio, start, duration, speaker_gender, bandwidth, speaker_id)
  @audio          = audio
  @start          = start
  @duration       = duration
  @bandwidth      = bandwidth
  @speaker_id     = speaker_id
  @speaker_gender = speaker_gender
end

Public Instance Methods

_as_json()
Alias for: as_json
_to_json()
Alias for: to_json
as_json() click to toggle source
# File lib/diarize/segment.rb, line 43
def as_json
  {
    'start' => start,
    'duration' => duration,
    'gender' => speaker_gender,
    'bandwidth' => bandwidth,
    'speaker_id' => speaker_id
  }.tap {|s|
    s['speaker'] = speaker.as_json if speaker
  }
end
Also aliased as: _as_json
namespaces() click to toggle source
Calls superclass method
# File lib/diarize/segment.rb, line 20
def namespaces
  super.merge({'ws' => 'http://wsarchive.prototype0.net/ontology/'})
end
rdf_mapping() click to toggle source
# File lib/diarize/segment.rb, line 33
def rdf_mapping
  {
    'ws:start' => start,
    'ws:duration' => duration,
    'ws:gender' => speaker_gender,
    'ws:bandwidth' => bandwidth,
    'ws:speaker' => speaker,
  }
end
speaker() click to toggle source
# File lib/diarize/segment.rb, line 16
def speaker
  Speaker.find_or_create(URI("#{@audio.base_uri}##{@speaker_id}"), @speaker_gender)
end
to_json() click to toggle source
# File lib/diarize/segment.rb, line 56
def to_json
  as_json.to_json
end
Also aliased as: _to_json
type_uri() click to toggle source
# File lib/diarize/segment.rb, line 29
def type_uri
  'ws:Segment'
end
uri() click to toggle source
# File lib/diarize/segment.rb, line 24
def uri
  # http://www.w3.org/TR/media-frags/
  URI("#{@audio.base_uri}#t=#{start},#{start + duration}")
end