Class: ESpeak::Speech
- Inherits:
-
Object
- Object
- ESpeak::Speech
- Defined in:
- lib/espeak/speech.rb
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
:quiet - remove printing to stdout. Affects only lame (default false)
14 15 16 17 |
# File 'lib/espeak/speech.rb', line 14 def initialize(text, ={}) @text = text @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/espeak/speech.rb', line 3 def @options end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
3 4 5 |
# File 'lib/espeak/speech.rb', line 3 def text @text end |
Instance Method Details
#bytes ⇒ Object
Returns mp3 file bytes as a result of Text-To-Speech conversion.
41 42 43 44 45 46 47 48 49 |
# File 'lib/espeak/speech.rb', line 41 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.
54 55 56 |
# File 'lib/espeak/speech.rb', line 54 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.
28 29 30 31 32 33 34 35 36 |
# File 'lib/espeak/speech.rb', line 28 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
21 22 23 |
# File 'lib/espeak/speech.rb', line 21 def speak IO.popen(espeak_command(), 'r').read end |