Class: Asimov::ApiV1::Audio

Inherits:
Base
  • Object
show all
Defined in:
lib/asimov/api_v1/audio.rb

Overview

Class interface for API methods in the “/audio” URI subspace.

Constant Summary collapse

RESOURCE =
"audio".freeze

Instance Method Summary collapse

Methods inherited from Base

#initialize, #rest_create_w_json_params, #rest_create_w_multipart_params, #rest_delete, #rest_get, #rest_get_streamed_download, #rest_index

Constructor Details

This class inherits a constructor from Asimov::ApiV1::Base

Instance Method Details

#create_transcription(file:, model:, parameters: {}) ⇒ Object

Creates a transcription request with the specified parameters.

Parameters:

  • model (String)

    the model to use for the completion

  • parameters (Hash) (defaults to: {})

    the set of parameters being passed to the API

Raises:



17
18
19
20
21
22
23
24
25
# File 'lib/asimov/api_v1/audio.rb', line 17

def create_transcription(file:, model:, parameters: {})
  raise MissingRequiredParameterError.new(:model) unless model

  rest_create_w_multipart_params(resource: [RESOURCE, "transcriptions"],
                                 parameters:
                                 open_file(parameters.merge({
                                                              file: file, model: model
                                                            })))
end

#create_translation(file:, model:, parameters: {}) ⇒ Object

Creates a transcription request with the specified parameters.

Parameters:

  • model (String)

    the model to use for the completion

  • parameters (Hash) (defaults to: {})

    the set of parameters being passed to the API

Raises:



33
34
35
36
37
38
39
40
41
# File 'lib/asimov/api_v1/audio.rb', line 33

def create_translation(file:, model:, parameters: {})
  raise MissingRequiredParameterError.new(:model) unless model

  rest_create_w_multipart_params(resource: [RESOURCE, "translations"],
                                 parameters:
                                 open_file(parameters.merge({
                                                              file: file, model: model
                                                            })))
end