Class: ESpeak::Voice

Inherits:
Object
  • Object
show all
Defined in:
lib/espeak/voice.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Voice

Returns a new instance of Voice.



6
7
8
9
10
11
# File 'lib/espeak/voice.rb', line 6

def initialize(attributes)
  @language = attributes[:language]
  @name     = attributes[:name]
  @gender   = attributes[:gender]
  @file     = attributes[:file]
end

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/espeak/voice.rb', line 5

def file
  @file
end

#genderObject (readonly)

Returns the value of attribute gender.



5
6
7
# File 'lib/espeak/voice.rb', line 5

def gender
  @gender
end

#languageObject (readonly)

Returns the value of attribute language.



5
6
7
# File 'lib/espeak/voice.rb', line 5

def language
  @language
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/espeak/voice.rb', line 5

def name
  @name
end

Class Method Details

.allObject



13
14
15
16
17
18
19
# File 'lib/espeak/voice.rb', line 13

def self.all
  voices = []
  CSV.parse(espeak_voices, headers: :first_row, col_sep: ' ') do |row|
    voices << Voice.new(language: row[1], gender: row[2], name: row[3], file: row[4] )
  end
  voices
end

.espeak_voicesObject



25
26
27
# File 'lib/espeak/voice.rb', line 25

def self.espeak_voices
  `espeak --voices`
end

.find_by_language(lang) ⇒ Object



21
22
23
# File 'lib/espeak/voice.rb', line 21

def self.find_by_language(lang)
  all.find { |v| v.language == lang.to_s }
end