Class: Voicemaker::TTS

Inherits:
Object
  • Object
show all
Defined in:
lib/voicemaker/tts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ TTS

Returns a new instance of TTS.



7
8
9
# File 'lib/voicemaker/tts.rb', line 7

def initialize(params = {})
  @params = TTSParams.new params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



5
6
7
# File 'lib/voicemaker/tts.rb', line 5

def params
  @params
end

Instance Method Details

#save(outpath) ⇒ Object

Saves the audio file



20
21
22
# File 'lib/voicemaker/tts.rb', line 20

def save(outpath)
  Down.download url, destination: outpath
end

#urlObject

Returns the URL for the generated file

Raises:



12
13
14
15
16
17
# File 'lib/voicemaker/tts.rb', line 12

def url
  response = API.post "api", params.api_params
  url = response['path']
  raise BadResponse, "Received empty URL: #{response}" unless url
  url
end