lib/azure_stt/client.rb in azure_stt-0.3.0 vs lib/azure_stt/client.rb in azure_stt-0.4.0
- old
+ new
@@ -1,9 +1,8 @@
# frozen_string_literal: true
require 'httparty'
-
module AzureSTT
#
# Client class that uses HTTParty to communicate with the API
#
class Client
@@ -18,17 +17,17 @@
# @param [String] region The region of your resources
#
def initialize(region:, subscription_key:)
@subscription_key = subscription_key
@region = region
- self.class.base_uri "https://#{region}.api.cognitive.microsoft.com/speechtotext/v3.0"
+ self.class.base_uri "https://#{region}.api.cognitive.microsoft.com/speechtotext/v3.1"
end
#
# Create a transcription for a batch or a single file.
#
- # @see https://francecentral.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-0/operations/CreateTranscription
+ # @see https://francecentral.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-1/operations/CreateTranscription
#
# @param [Hash] args
#
# @return [Hash] The JSON body response, parsed by HTTParty
#
@@ -90,11 +89,11 @@
end
#
# Get an array containing the files for a given transcription
#
- # @see https://uscentral.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-0/operations/GetTranscriptionFiles
+ # @see https://uscentral.dev.cognitive.microsoft.com/docs/services/speech-to-text-api-v3-1/operations/GetTranscriptionFiles
#
# @param [Integer] id The identifier of the transcription
#
# @return [Array[Hash]] Array of the files of a transcription
#
@@ -145,13 +144,14 @@
# @param [String] path the path, which is added to the base_uri
# @param [Hash] parameters The parameters you want to add to the headers (empty by default)
#
# @return [HTTParty::Response]
#
- def get(path, parameters = {})
+ def get(path, parameters = nil)
options = {
- headers: headers.merge(parameters)
+ headers: headers,
+ query: parameters
}.compact
response = self.class.get(path, options)
handle_response(response)
end
@@ -175,15 +175,16 @@
response
else
if response.request.format == :json
raise ServiceError.new(
code: response.code,
- message: response.response.message
+ message: response['code'] || response.message,
+ azure_message: response['message'] || response.dig('error', 'message')
)
else
raise NetError.new(
code: response.code,
- message: response.response.message
+ message: response.message
)
end
end
end