Class: OpenApiOpenAIClient::AudioApi
- Inherits:
-
Object
- Object
- OpenApiOpenAIClient::AudioApi
- Defined in:
- lib/openapi_openai/api/audio_api.rb
Instance Attribute Summary collapse
-
#api_client ⇒ Object
Returns the value of attribute api_client.
Instance Method Summary collapse
-
#create_speech(create_speech_request, opts = {}) ⇒ File
Generates audio from the input text.
-
#create_speech_with_http_info(create_speech_request, opts = {}) ⇒ Array<(File, Integer, Hash)>
Generates audio from the input text.
-
#create_transcription(file, model, opts = {}) ⇒ CreateTranscription200Response
Transcribes audio into the input language.
-
#create_transcription_with_http_info(file, model, opts = {}) ⇒ Array<(CreateTranscription200Response, Integer, Hash)>
Transcribes audio into the input language.
-
#create_translation(file, model, opts = {}) ⇒ CreateTranslation200Response
Translates audio into English.
-
#create_translation_with_http_info(file, model, opts = {}) ⇒ Array<(CreateTranslation200Response, Integer, Hash)>
Translates audio into English.
-
#initialize(api_client = ApiClient.default) ⇒ AudioApi
constructor
A new instance of AudioApi.
Constructor Details
Instance Attribute Details
#api_client ⇒ Object
Returns the value of attribute api_client.
17 18 19 |
# File 'lib/openapi_openai/api/audio_api.rb', line 17 def api_client @api_client end |
Instance Method Details
#create_speech(create_speech_request, opts = {}) ⇒ File
Generates audio from the input text.
26 27 28 29 |
# File 'lib/openapi_openai/api/audio_api.rb', line 26 def create_speech(create_speech_request, opts = {}) data, _status_code, _headers = create_speech_with_http_info(create_speech_request, opts) data end |
#create_speech_with_http_info(create_speech_request, opts = {}) ⇒ Array<(File, Integer, Hash)>
Generates audio from the input text.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/openapi_openai/api/audio_api.rb', line 35 def create_speech_with_http_info(create_speech_request, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AudioApi.create_speech ...' end # verify the required parameter 'create_speech_request' is set if @api_client.config.client_side_validation && create_speech_request.nil? fail ArgumentError, "Missing the required parameter 'create_speech_request' when calling AudioApi.create_speech" end # resource path local_var_path = '/audio/speech' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/octet-stream']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(create_speech_request) # return_type return_type = opts[:debug_return_type] || 'File' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"AudioApi.create_speech", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: AudioApi#create_speech\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_transcription(file, model, opts = {}) ⇒ CreateTranscription200Response
Transcribes audio into the input language.
98 99 100 101 |
# File 'lib/openapi_openai/api/audio_api.rb', line 98 def create_transcription(file, model, opts = {}) data, _status_code, _headers = create_transcription_with_http_info(file, model, opts) data end |
#create_transcription_with_http_info(file, model, opts = {}) ⇒ Array<(CreateTranscription200Response, Integer, Hash)>
Transcribes audio into the input language.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/openapi_openai/api/audio_api.rb', line 113 def create_transcription_with_http_info(file, model, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AudioApi.create_transcription ...' end # verify the required parameter 'file' is set if @api_client.config.client_side_validation && file.nil? fail ArgumentError, "Missing the required parameter 'file' when calling AudioApi.create_transcription" end # verify the required parameter 'model' is set if @api_client.config.client_side_validation && model.nil? fail ArgumentError, "Missing the required parameter 'model' when calling AudioApi.create_transcription" end allowable_values = ["json", "text", "srt", "verbose_json", "vtt"] if @api_client.config.client_side_validation && opts[:'response_format'] && !allowable_values.include?(opts[:'response_format']) fail ArgumentError, "invalid value for \"response_format\", must be one of #{allowable_values}" end allowable_values = ["word", "segment"] if @api_client.config.client_side_validation && opts[:'timestamp_granularities'] && !opts[:'timestamp_granularities'].all? { |item| allowable_values.include?(item) } fail ArgumentError, "invalid value for \"timestamp_granularities\", must include one of #{allowable_values}" end # resource path local_var_path = '/audio/transcriptions' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['file'] = file form_params['model'] = model form_params['language'] = opts[:'language'] if !opts[:'language'].nil? form_params['prompt'] = opts[:'prompt'] if !opts[:'prompt'].nil? form_params['response_format'] = opts[:'response_format'] if !opts[:'response_format'].nil? form_params['temperature'] = opts[:'temperature'] if !opts[:'temperature'].nil? form_params['timestamp_granularities[]'] = @api_client.build_collection_param(opts[:'timestamp_granularities'], :csv) if !opts[:'timestamp_granularities'].nil? # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CreateTranscription200Response' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"AudioApi.create_transcription", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: AudioApi#create_transcription\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |
#create_translation(file, model, opts = {}) ⇒ CreateTranslation200Response
Translates audio into English.
193 194 195 196 |
# File 'lib/openapi_openai/api/audio_api.rb', line 193 def create_translation(file, model, opts = {}) data, _status_code, _headers = create_translation_with_http_info(file, model, opts) data end |
#create_translation_with_http_info(file, model, opts = {}) ⇒ Array<(CreateTranslation200Response, Integer, Hash)>
Translates audio into English.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/openapi_openai/api/audio_api.rb', line 206 def create_translation_with_http_info(file, model, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: AudioApi.create_translation ...' end # verify the required parameter 'file' is set if @api_client.config.client_side_validation && file.nil? fail ArgumentError, "Missing the required parameter 'file' when calling AudioApi.create_translation" end # verify the required parameter 'model' is set if @api_client.config.client_side_validation && model.nil? fail ArgumentError, "Missing the required parameter 'model' when calling AudioApi.create_translation" end # resource path local_var_path = '/audio/translations' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['file'] = file form_params['model'] = model form_params['prompt'] = opts[:'prompt'] if !opts[:'prompt'].nil? form_params['response_format'] = opts[:'response_format'] if !opts[:'response_format'].nil? form_params['temperature'] = opts[:'temperature'] if !opts[:'temperature'].nil? # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CreateTranslation200Response' # auth_names auth_names = opts[:debug_auth_names] || ['ApiKeyAuth'] = opts.merge( :operation => :"AudioApi.create_translation", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, ) if @api_client.config.debugging @api_client.config.logger.debug "API called: AudioApi#create_translation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end |