Class: YandexSpeechApi::Speaker
- Inherits:
-
Object
- Object
- YandexSpeechApi::Speaker
- Includes:
- Setters
- Defined in:
- lib/yandex_speech.rb,
lib/yandex_speech/speaker.rb
Overview
class << self
Instance Attribute Summary collapse
-
#emotion ⇒ String
readonly
How emotional dictor should speak.
-
#format ⇒ Symbol
readonly
How remote server should decode audio data for us.
-
#language ⇒ String
readonly
Speaker language.
-
#speed ⇒ Float
readonly
Dictor speech speed.
-
#voice ⇒ Symbol
readonly
Preferred dictor voice.
Instance Method Summary collapse
- #initialize(settings = {}, &callback) {|_self| ... } ⇒ YandexSpeechApi::Speaker constructor
- #key ⇒ String, NilClass
-
#save_to_file(text, path_to_file = '') ⇒ String
Saves synthesized voice to audio-file.
-
#say(text) ⇒ NilClass
Speaks the text.
Methods included from Setters
#emotion=, #format=, #key=, #language=, #speed=, #voice=
Constructor Details
#initialize(settings = {}, &callback) {|_self| ... } ⇒ YandexSpeechApi::Speaker
118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/yandex_speech.rb', line 118 def initialize(settings = {}, &callback) yield self if block_given? self.key = settings[:key] self.voice ||= settings[:voice] || "jane" self.speed ||= settings[:speed] || 1.0 self.emotion ||= settings[:emotion] || "good" self.language ||= settings[:language] || "english" self.format ||= settings[:format] || "mp3" end |
Instance Attribute Details
#emotion ⇒ String (readonly)
How emotional dictor should speak.
88 89 90 |
# File 'lib/yandex_speech.rb', line 88 def emotion @emotion end |
#format ⇒ Symbol (readonly)
How remote server should decode audio data for us.
Do not use +:wav+ format for large texts. Result audio file will be
too big, and service truncates resulted file.
111 112 113 |
# File 'lib/yandex_speech.rb', line 111 def format @format end |
#language ⇒ String (readonly)
Speaker language.
Speaker with +russian+ language can't translate, or even synthesize
+english+ text (actually it can, but official documentation strongly
recommend to select correct language for text)
100 101 102 |
# File 'lib/yandex_speech.rb', line 100 def language @language end |
#speed ⇒ Float (readonly)
Dictor speech speed.
72 73 74 |
# File 'lib/yandex_speech.rb', line 72 def speed @speed end |
#voice ⇒ Symbol (readonly)
Preferred dictor voice.
80 81 82 |
# File 'lib/yandex_speech.rb', line 80 def voice @voice end |
Instance Method Details
#key ⇒ String, NilClass
62 63 64 |
# File 'lib/yandex_speech.rb', line 62 def key YandexSpeechApi.key || @key end |
#save_to_file(text, path_to_file = '') ⇒ String
Saves synthesized voice to audio-file.
158 159 160 161 162 163 164 165 166 |
# File 'lib/yandex_speech.rb', line 158 def save_to_file(text, path_to_file = '') path_to_file = generate_path if path_to_file.empty? row_data = request text absolute_path = "#{File.(path_to_file)}.#{format}" File.open(absolute_path, 'w') { |f| f.write row_data } return absolute_path end |