class SSMD::Annotations::ProsodyAnnotation
Attributes
pitch[R]
rate[R]
volume[R]
Public Class Methods
new(vrp, *tuples)
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 44 def initialize(vrp, *tuples) begin if vrp && vrp.size == 3 set_vrp! vrp elsif tuples.compact.size % 2 == 0 set_tuples! tuples.take(6) else # ignore invalid values end rescue ArgumentError # ignore if there are invalid values end end
pitches()
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 31 def pitches { 1 => "x-low", 2 => "low", 3 => "medium", 4 => "high", 5 => "x-high" } end
rates()
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 21 def rates { 1 => "x-slow", 2 => "slow", 3 => "medium", 4 => "fast", 5 => "x-fast" } end
regex()
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 6 def regex /(?:vrp: ?(\d{3}))|(?:([vrp]): ?(\d))/ end
volumes()
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 10 def volumes { 0 => "silent", 1 => "x-soft", 2 => "soft", 3 => "medium", 4 => "loud", 5 => "x-loud" } end
Public Instance Methods
combine(annotation)
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 70 def combine(annotation) @volume ||= annotation.volume @rate ||= annotation.rate @pitch ||= annotation.pitch self end
wrap(text)
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 58 def wrap(text) attributes = [ "", ("volume=\"#{volume}\"" if volume), ("rate=\"#{rate}\"" if rate), ("pitch=\"#{pitch}\"" if pitch) ] .compact "<prosody#{attributes.join(' ')}>#{text}</prosody>" end
Private Instance Methods
set_tuples!(tuples)
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 86 def set_tuples!(tuples) tuples.each_slice(2).each do |key, value| case key when 'v' @volume = self.class.volumes.fetch Integer(value) when 'r' @rate = self.class.rates.fetch Integer(value) when 'p' @pitch = self.class.pitches.fetch Integer(value) end end end
set_vrp!(vrp)
click to toggle source
# File lib/ssmd/annotations/prosody_annotation.rb, line 80 def set_vrp!(vrp) @volume = self.class.volumes.fetch Integer(vrp[0]) @rate = self.class.rates.fetch Integer(vrp[1]) @pitch = self.class.pitches.fetch Integer(vrp[2]) end