Class: ESpeak::Speech
- Inherits:
-
Object
- Object
- ESpeak::Speech
- Defined in:
- lib/espeak/speech.rb
Overview
Speech represents an Text-To-Speech audio that can be played or saved to file
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#bytes ⇒ Object
Returns mp3 file bytes as a result of Text-To-Speech conversion.
-
#bytes_wav ⇒ Object
Returns wav file bytes as a result of Text-To-Speech conversion.
-
#initialize(text, options = {}) ⇒ Speech
constructor
filename - The file that will be generated options - Posible key, values :voice - use voice file of this name from espeak-data/voices.
-
#save(filename) ⇒ Object
Generates mp3 file as a result of Text-To-Speech conversion.
-
#speak ⇒ Object
Speaks text.
Constructor Details
#initialize(text, options = {}) ⇒ Speech
filename - The file that will be generated options - Posible key, values :voice - use voice file of this name from espeak-data/voices. ie 'en', 'de', ... :pitch - pitch adjustment, 0 to 99 :speed - speed in words per minute, 80 to 370 :capital - increase emphasis of capitalized letters by raising pitch by this amount no range given in man but good range is 10-40 to start :amplitude - amplitude adjustment, 0 to 200 :quiet - remove printing to stdout. Affects only lame (default false)
18 19 20 21 |
# File 'lib/espeak/speech.rb', line 18 def initialize(text, = {}) @text = text @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/espeak/speech.rb', line 6 def @options end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
6 7 8 |
# File 'lib/espeak/speech.rb', line 6 def text @text end |
Instance Method Details
#bytes ⇒ Object
Returns mp3 file bytes as a result of Text-To-Speech conversion.
45 46 47 48 49 50 51 52 53 |
# File 'lib/espeak/speech.rb', line 45 def bytes speech = bytes_wav res = IO.popen(std_lame_command(), 'r+') do |process| process.write(speech) process.close_write process.read end res.to_s end |
#bytes_wav ⇒ Object
Returns wav file bytes as a result of Text-To-Speech conversion.
58 59 60 |
# File 'lib/espeak/speech.rb', line 58 def bytes_wav IO.popen(espeak_command(, '--stdout'), 'r', &:read) end |
#save(filename) ⇒ Object
Generates mp3 file as a result of Text-To-Speech conversion.
32 33 34 35 36 37 38 39 40 |
# File 'lib/espeak/speech.rb', line 32 def save(filename) speech = bytes_wav res = IO.popen(lame_command(filename, ), 'r+') do |process| process.write(speech) process.close_write process.read end res.to_s end |
#speak ⇒ Object
Speaks text
25 26 27 |
# File 'lib/espeak/speech.rb', line 25 def speak IO.popen(espeak_command(), 'r', &:read) end |