Skip to content

explicitly specify binary mode reading audio file #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/att/codekit/model/speech.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/att/codekit/service/speech.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down