diff --git a/lib/att/codekit/model/speech.rb b/lib/att/codekit/model/speech.rb index 943a185..6f10c6f 100644 --- a/lib/att/codekit/model/speech.rb +++ b/lib/att/codekit/model/speech.rb @@ -7,6 +7,9 @@ module Model # Response of a speech request class SpeechResponse < ImmutableStruct.new(:id, :status, :nbest) + + attr_accessor :original_json + # @!attribute [r] id # @return [String] the id of the request made # @!attribute [r] status @@ -20,7 +23,9 @@ class SpeechResponse < ImmutableStruct.new(:id, :status, :nbest) # # @return [SpeechResponse] a parsed object def self.createFromJson(json) - self.createFromParsedJson(JSON.parse(json)) + newobj = self.createFromParsedJson(JSON.parse(json)) + newobj.original_json = json + newobj end # Factory method to create an object from a json string diff --git a/lib/att/codekit/service/speech.rb b/lib/att/codekit/service/speech.rb index 1b8b73a..43b6457 100644 --- a/lib/att/codekit/service/speech.rb +++ b/lib/att/codekit/service/speech.rb @@ -51,7 +51,7 @@ def stdSpeechToText(file, opts={}) x_arg_val = URI.escape(xArgs) - filecontents = File.read(file) + filecontents = File.read(file, :mode => "rb") filetype = CloudService.getMimeType file @@ -124,7 +124,7 @@ def customSpeechToText(audio_file, dictionary, grammar, opts={}) } file_part = { :headers => fheaders, - :data => File.read(audio_file) + :data => File.read(audio_file, :mode => "rb") } multipart = [dict_part, grammar_part, file_part]