Class: Diarize::Segment
- Inherits:
-
Object
- Object
- Diarize::Segment
- Includes:
- ToRdf
- Defined in:
- lib/diarize/segment.rb
Instance Attribute Summary collapse
-
#bandwidth ⇒ Object
readonly
Returns the value of attribute bandwidth.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#gender ⇒ Object
readonly
Returns the value of attribute gender.
-
#start ⇒ Object
readonly
Returns the value of attribute start.
Instance Method Summary collapse
-
#initialize(audio, start, duration, gender, bandwidth, speaker_id) ⇒ Segment
constructor
A new instance of Segment.
- #namespaces ⇒ Object
- #play ⇒ Object
- #rdf_mapping ⇒ Object
- #speaker ⇒ Object
- #type_uri ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(audio, start, duration, gender, bandwidth, speaker_id) ⇒ Segment
Returns a new instance of Segment.
29 30 31 32 33 34 35 36 |
# File 'lib/diarize/segment.rb', line 29 def initialize(audio, start, duration, gender, bandwidth, speaker_id) @audio = audio @start = start @duration = duration @bandwidth = bandwidth @speaker_id = speaker_id @speaker_gender = gender end |
Instance Attribute Details
#bandwidth ⇒ Object (readonly)
Returns the value of attribute bandwidth.
27 28 29 |
# File 'lib/diarize/segment.rb', line 27 def bandwidth @bandwidth end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
27 28 29 |
# File 'lib/diarize/segment.rb', line 27 def duration @duration end |
#gender ⇒ Object (readonly)
Returns the value of attribute gender.
27 28 29 |
# File 'lib/diarize/segment.rb', line 27 def gender @gender end |
#start ⇒ Object (readonly)
Returns the value of attribute start.
27 28 29 |
# File 'lib/diarize/segment.rb', line 27 def start @start end |
Instance Method Details
#namespaces ⇒ Object
49 50 51 |
# File 'lib/diarize/segment.rb', line 49 def namespaces super.merge 'ws' => 'http://wsarchive.prototype0.net/ontology/' end |
#play ⇒ Object
42 43 44 45 |
# File 'lib/diarize/segment.rb', line 42 def play player = AudioPlayer.new player.play(@audio.file, start, duration) end |
#rdf_mapping ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/diarize/segment.rb', line 62 def rdf_mapping { 'ws:start' => start, 'ws:duration' => duration, 'ws:gender' => gender, 'ws:bandwidth' => bandwidth, 'ws:speaker' => speaker, } end |
#speaker ⇒ Object
38 39 40 |
# File 'lib/diarize/segment.rb', line 38 def speaker Speaker.find_or_create(URI("#{@audio.base_uri}##{@speaker_id}"), @speaker_gender) end |
#type_uri ⇒ Object
58 59 60 |
# File 'lib/diarize/segment.rb', line 58 def type_uri 'ws:Segment' end |
#uri ⇒ Object
53 54 55 56 |
# File 'lib/diarize/segment.rb', line 53 def uri # http://www.w3.org/TR/media-frags/ URI("#{@audio.base_uri}#t=#{start},#{start+duration}") end |