Class: Miles::Tts

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/miles/tts.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = 80) ⇒ Tts

Returns a new instance of Tts.



10
11
12
13
14
15
# File 'lib/miles/tts.rb', line 10

def initialize(host, port=80)
	@host = host
	@port = port
	@base_uri = "#{host}#{port != 80 ? ':' + @port.to_s : ''}"
	self.class.base_uri @base_uri
end

Instance Attribute Details

#base_uriObject (readonly)

Returns the value of attribute base_uri.



8
9
10
# File 'lib/miles/tts.rb', line 8

def base_uri
  @base_uri
end

#hostObject (readonly)

Returns the value of attribute host.



8
9
10
# File 'lib/miles/tts.rb', line 8

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



8
9
10
# File 'lib/miles/tts.rb', line 8

def port
  @port
end

Instance Method Details

#get_mp3(text) ⇒ Object



17
18
19
20
21
22
# File 'lib/miles/tts.rb', line 17

def get_mp3(text)
	req = {'text' => text}
	response = self.class.post('/tts', :body => JSON.dump(req))
	audio = response.body
	return audio
end