Class: Miles::Stt
Instance Attribute Summary collapse
-
#base_uri ⇒ Object
readonly
Returns the value of attribute base_uri.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #get_text(file_path) ⇒ Object
-
#initialize(host, port = 80) ⇒ Stt
constructor
A new instance of Stt.
Constructor Details
#initialize(host, port = 80) ⇒ Stt
Returns a new instance of Stt.
10 11 12 13 14 15 |
# File 'lib/miles/stt.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_uri ⇒ Object (readonly)
Returns the value of attribute base_uri.
8 9 10 |
# File 'lib/miles/stt.rb', line 8 def base_uri @base_uri end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/miles/stt.rb', line 8 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/miles/stt.rb', line 8 def port @port end |
Instance Method Details
#get_text(file_path) ⇒ Object
17 18 19 20 21 |
# File 'lib/miles/stt.rb', line 17 def get_text(file_path) contents = open(file_path, "rb") {|io| io.read } response = self.class.post('/recognize', :body => contents, :headers => {'Content-type' => 'audio/mpeg'}) return JSON.parse(response.body) end |