Module: YandexSpeechApi::Connection

Defined in:
lib/yandex_speech/connection.rb

Overview

no-doc

Defined Under Namespace

Classes: ConnectionError

Class Method Summary collapse

Class Method Details

.send(**params) ⇒ String

Sends :get request.

Options Hash (**params):

  • :text (String)
  • :format (Symbol)
  • :lang (String)
  • :speaker (String)
  • :emotion (Symbol)
  • :speed (Float)
  • :key (String, Symbol)


25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/yandex_speech/connection.rb', line 25

def send(**params)
  uri = URI.parse URL
  uri.query = URI.encode_www_form params
  response = Net::HTTP.get_response uri

  case response
  when Net::HTTPSuccess
    return response.body
  else
    raise ConnectionError.new response.code, response.message
  end
end