ibm_watson 0.20.1 → 1.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +46 -60
  3. data/lib/ibm_watson.rb +0 -2
  4. data/lib/ibm_watson/assistant_v1.rb +82 -60
  5. data/lib/ibm_watson/assistant_v2.rb +8 -12
  6. data/lib/ibm_watson/compare_comply_v1.rb +21 -18
  7. data/lib/ibm_watson/discovery_v1.rb +107 -55
  8. data/lib/ibm_watson/language_translator_v3.rb +21 -23
  9. data/lib/ibm_watson/natural_language_classifier_v1.rb +15 -24
  10. data/lib/ibm_watson/natural_language_understanding_v1.rb +8 -12
  11. data/lib/ibm_watson/personality_insights_v3.rb +12 -24
  12. data/lib/ibm_watson/speech_to_text_v1.rb +90 -54
  13. data/lib/ibm_watson/text_to_speech_v1.rb +38 -32
  14. data/lib/ibm_watson/tone_analyzer_v3.rb +13 -24
  15. data/lib/ibm_watson/version.rb +1 -1
  16. data/lib/ibm_watson/visual_recognition_v3.rb +37 -25
  17. data/test/integration/test_assistant_v1.rb +8 -4
  18. data/test/integration/test_assistant_v2.rb +6 -1
  19. data/test/integration/test_compare_comply_v1.rb +6 -2
  20. data/test/integration/test_discovery_v1.rb +4 -1
  21. data/test/integration/test_language_translator_v3.rb +4 -16
  22. data/test/integration/test_natural_language_classifier_v1.rb +4 -1
  23. data/test/integration/test_natural_language_understanding_v1.rb +4 -1
  24. data/test/integration/test_personality_insights_v3.rb +5 -2
  25. data/test/integration/test_speech_to_text_v1.rb +9 -3
  26. data/test/integration/test_text_to_speech_v1.rb +5 -2
  27. data/test/integration/test_tone_analyzer_v3.rb +5 -2
  28. data/test/integration/test_visual_recognition_v3.rb +5 -2
  29. data/test/test_helper.rb +2 -0
  30. data/test/unit/test_assistant_v1.rb +269 -133
  31. data/test/unit/test_assistant_v2.rb +18 -9
  32. data/test/unit/test_compare_comply_v1.rb +72 -40
  33. data/test/unit/test_configure_http_client.rb +4 -2
  34. data/test/unit/test_discovery_v1.rb +297 -152
  35. data/test/unit/test_language_translator_v3.rb +52 -13
  36. data/test/unit/test_natural_language_classifier_v1.rb +10 -4
  37. data/test/unit/test_natural_language_understanding_v1.rb +25 -10
  38. data/test/unit/test_personality_insights_v3.rb +20 -8
  39. data/test/unit/test_speech_to_text_v1.rb +84 -21
  40. data/test/unit/test_text_to_speech_v1.rb +30 -5
  41. data/test/unit/test_tone_analyzer_v3.rb +30 -12
  42. data/test/unit/test_vcap_using_personality_insights.rb +12 -4
  43. data/test/unit/test_visual_recognition_v3.rb +37 -10
  44. metadata +8 -8
  45. data/test/unit/test_watson_service.rb +0 -59
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 IBM All Rights Reserved.
3
+ # (C) Copyright IBM Corp. 2019.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -71,12 +71,6 @@ module IBMWatson
71
71
  # 'https://iam.cloud.ibm.com/identity/token'.
72
72
  # @option args iam_client_id [String] An optional client id for the IAM service API.
73
73
  # @option args iam_client_secret [String] An optional client secret for the IAM service API.
74
- # @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
75
- # fully managed by the application. Responsibility falls on the application to
76
- # refresh the token, either before it expires or reactively upon receiving a 401
77
- # from the service as any requests made with an expired token will fail.
78
- # @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
79
- # URL must be passed in.
80
74
  # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
81
75
  # takes are basic, iam or icp4d.
82
76
  def initialize(args = {})
@@ -84,21 +78,14 @@ module IBMWatson
84
78
  defaults = {}
85
79
  defaults[:version] = nil
86
80
  defaults[:url] = "https://gateway.watsonplatform.net/language-translator/api"
87
- defaults[:username] = nil
88
- defaults[:password] = nil
89
- defaults[:iam_apikey] = nil
90
- defaults[:iam_access_token] = nil
91
- defaults[:iam_url] = nil
92
- defaults[:iam_client_id] = nil
93
- defaults[:iam_client_secret] = nil
94
- defaults[:icp4d_access_token] = nil
95
- defaults[:icp4d_url] = nil
81
+ defaults[:authenticator] = nil
96
82
  defaults[:authentication_type] = nil
97
83
  args = defaults.merge(args)
98
- args[:vcap_services_name] = "language_translator"
84
+ @version = args[:version]
85
+ raise ArgumentError.new("version must be provided") if @version.nil?
86
+
99
87
  args[:display_name] = "Language Translator"
100
88
  super
101
- @version = args[:version]
102
89
  end
103
90
 
104
91
  #########################
@@ -137,6 +124,7 @@ module IBMWatson
137
124
 
138
125
  method_url = "/v3/translate"
139
126
 
127
+ headers = authenticator.authenticate(headers)
140
128
  response = request(
141
129
  method: "POST",
142
130
  url: method_url,
@@ -169,6 +157,7 @@ module IBMWatson
169
157
 
170
158
  method_url = "/v3/identifiable_languages"
171
159
 
160
+ headers = authenticator.authenticate(headers)
172
161
  response = request(
173
162
  method: "GET",
174
163
  url: method_url,
@@ -202,6 +191,7 @@ module IBMWatson
202
191
 
203
192
  method_url = "/v3/identify"
204
193
 
194
+ headers = authenticator.authenticate(headers)
205
195
  response = request(
206
196
  method: "POST",
207
197
  url: method_url,
@@ -217,17 +207,17 @@ module IBMWatson
217
207
  #########################
218
208
 
219
209
  ##
220
- # @!method list_models(source: nil, target: nil, default_models: nil)
210
+ # @!method list_models(source: nil, target: nil, default: nil)
221
211
  # List models.
222
212
  # Lists available translation models.
223
213
  # @param source [String] Specify a language code to filter results by source language.
224
214
  # @param target [String] Specify a language code to filter results by target language.
225
- # @param default_models [Boolean] If the default parameter isn't specified, the service will return all models
215
+ # @param default [Boolean] If the default parameter isn't specified, the service will return all models
226
216
  # (default and non-default) for each language pair. To return only default models,
227
217
  # set this to `true`. To return only non-default models, set this to `false`. There
228
218
  # is exactly one default model per language pair, the IBM provided base model.
229
219
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
230
- def list_models(source: nil, target: nil, default_models: nil)
220
+ def list_models(source: nil, target: nil, default: nil)
231
221
  headers = {
232
222
  }
233
223
  sdk_headers = Common.new.get_sdk_headers("language_translator", "V3", "list_models")
@@ -237,11 +227,12 @@ module IBMWatson
237
227
  "version" => @version,
238
228
  "source" => source,
239
229
  "target" => target,
240
- "default" => default_models
230
+ "default" => default
241
231
  }
242
232
 
243
233
  method_url = "/v3/models"
244
234
 
235
+ headers = authenticator.authenticate(headers)
245
236
  response = request(
246
237
  method: "GET",
247
238
  url: method_url,
@@ -318,6 +309,7 @@ module IBMWatson
318
309
 
319
310
  method_url = "/v3/models"
320
311
 
312
+ headers = authenticator.authenticate(headers)
321
313
  response = request(
322
314
  method: "POST",
323
315
  url: method_url,
@@ -349,6 +341,7 @@ module IBMWatson
349
341
 
350
342
  method_url = "/v3/models/%s" % [ERB::Util.url_encode(model_id)]
351
343
 
344
+ headers = authenticator.authenticate(headers)
352
345
  response = request(
353
346
  method: "DELETE",
354
347
  url: method_url,
@@ -381,6 +374,7 @@ module IBMWatson
381
374
 
382
375
  method_url = "/v3/models/%s" % [ERB::Util.url_encode(model_id)]
383
376
 
377
+ headers = authenticator.authenticate(headers)
384
378
  response = request(
385
379
  method: "GET",
386
380
  url: method_url,
@@ -411,6 +405,7 @@ module IBMWatson
411
405
 
412
406
  method_url = "/v3/documents"
413
407
 
408
+ headers = authenticator.authenticate(headers)
414
409
  response = request(
415
410
  method: "GET",
416
411
  url: method_url,
@@ -444,7 +439,6 @@ module IBMWatson
444
439
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
445
440
  def translate_document(file:, filename: nil, file_content_type: nil, model_id: nil, source: nil, target: nil, document_id: nil)
446
441
  raise ArgumentError.new("file must be provided") if file.nil?
447
- raise ArgumentError.new("filename must be provided") if filename.nil?
448
442
 
449
443
  headers = {
450
444
  }
@@ -473,6 +467,7 @@ module IBMWatson
473
467
 
474
468
  method_url = "/v3/documents"
475
469
 
470
+ headers = authenticator.authenticate(headers)
476
471
  response = request(
477
472
  method: "POST",
478
473
  url: method_url,
@@ -504,6 +499,7 @@ module IBMWatson
504
499
 
505
500
  method_url = "/v3/documents/%s" % [ERB::Util.url_encode(document_id)]
506
501
 
502
+ headers = authenticator.authenticate(headers)
507
503
  response = request(
508
504
  method: "GET",
509
505
  url: method_url,
@@ -534,6 +530,7 @@ module IBMWatson
534
530
 
535
531
  method_url = "/v3/documents/%s" % [ERB::Util.url_encode(document_id)]
536
532
 
533
+ headers = authenticator.authenticate(headers)
537
534
  request(
538
535
  method: "DELETE",
539
536
  url: method_url,
@@ -578,6 +575,7 @@ module IBMWatson
578
575
 
579
576
  method_url = "/v3/documents/%s/translated_document" % [ERB::Util.url_encode(document_id)]
580
577
 
578
+ headers = authenticator.authenticate(headers)
581
579
  response = request(
582
580
  method: "GET",
583
581
  url: method_url,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 IBM All Rights Reserved.
3
+ # (C) Copyright IBM Corp. 2019.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -60,30 +60,15 @@ module IBMWatson
60
60
  # 'https://iam.cloud.ibm.com/identity/token'.
61
61
  # @option args iam_client_id [String] An optional client id for the IAM service API.
62
62
  # @option args iam_client_secret [String] An optional client secret for the IAM service API.
63
- # @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
64
- # fully managed by the application. Responsibility falls on the application to
65
- # refresh the token, either before it expires or reactively upon receiving a 401
66
- # from the service as any requests made with an expired token will fail.
67
- # @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
68
- # URL must be passed in.
69
63
  # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
70
64
  # takes are basic, iam or icp4d.
71
65
  def initialize(args = {})
72
66
  @__async_initialized__ = false
73
67
  defaults = {}
74
68
  defaults[:url] = "https://gateway.watsonplatform.net/natural-language-classifier/api"
75
- defaults[:username] = nil
76
- defaults[:password] = nil
77
- defaults[:iam_apikey] = nil
78
- defaults[:iam_access_token] = nil
79
- defaults[:iam_url] = nil
80
- defaults[:iam_client_id] = nil
81
- defaults[:iam_client_secret] = nil
82
- defaults[:icp4d_access_token] = nil
83
- defaults[:icp4d_url] = nil
69
+ defaults[:authenticator] = nil
84
70
  defaults[:authentication_type] = nil
85
71
  args = defaults.merge(args)
86
- args[:vcap_services_name] = "natural_language_classifier"
87
72
  args[:display_name] = "Natural Language Classifier"
88
73
  super
89
74
  end
@@ -116,6 +101,7 @@ module IBMWatson
116
101
 
117
102
  method_url = "/v1/classifiers/%s/classify" % [ERB::Util.url_encode(classifier_id)]
118
103
 
104
+ headers = authenticator.authenticate(headers)
119
105
  response = request(
120
106
  method: "POST",
121
107
  url: method_url,
@@ -152,6 +138,7 @@ module IBMWatson
152
138
 
153
139
  method_url = "/v1/classifiers/%s/classify_collection" % [ERB::Util.url_encode(classifier_id)]
154
140
 
141
+ headers = authenticator.authenticate(headers)
155
142
  response = request(
156
143
  method: "POST",
157
144
  url: method_url,
@@ -166,11 +153,11 @@ module IBMWatson
166
153
  #########################
167
154
 
168
155
  ##
169
- # @!method create_classifier(metadata:, training_data:)
156
+ # @!method create_classifier(training_metadata:, training_data:)
170
157
  # Create classifier.
171
158
  # Sends data to create and train a classifier and returns information about the new
172
159
  # classifier.
173
- # @param metadata [File] Metadata in JSON format. The metadata identifies the language of the data, and an
160
+ # @param training_metadata [File] Metadata in JSON format. The metadata identifies the language of the data, and an
174
161
  # optional name to identify the classifier. Specify the language with the 2-letter
175
162
  # primary language code as assigned in ISO standard 639.
176
163
  #
@@ -181,8 +168,8 @@ module IBMWatson
181
168
  # data can include up to 3,000 classes and 20,000 records. For details, see [Data
182
169
  # preparation](https://cloud.ibm.com/docs/services/natural-language-classifier?topic=natural-language-classifier-using-your-data).
183
170
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
184
- def create_classifier(metadata:, training_data:)
185
- raise ArgumentError.new("metadata must be provided") if metadata.nil?
171
+ def create_classifier(training_metadata:, training_data:)
172
+ raise ArgumentError.new("training_metadata must be provided") if training_metadata.nil?
186
173
 
187
174
  raise ArgumentError.new("training_data must be provided") if training_data.nil?
188
175
 
@@ -193,10 +180,10 @@ module IBMWatson
193
180
 
194
181
  form_data = {}
195
182
 
196
- unless metadata.instance_of?(StringIO) || metadata.instance_of?(File)
197
- metadata = metadata.respond_to?(:to_json) ? StringIO.new(metadata.to_json) : StringIO.new(metadata)
183
+ unless training_metadata.instance_of?(StringIO) || training_metadata.instance_of?(File)
184
+ training_metadata = training_metadata.respond_to?(:to_json) ? StringIO.new(training_metadata.to_json) : StringIO.new(training_metadata)
198
185
  end
199
- form_data[:training_metadata] = HTTP::FormData::File.new(metadata, content_type: "application/json", filename: metadata.respond_to?(:path) ? metadata.path : nil)
186
+ form_data[:training_metadata] = HTTP::FormData::File.new(training_metadata, content_type: "application/json", filename: training_metadata.respond_to?(:path) ? training_metadata.path : nil)
200
187
 
201
188
  unless training_data.instance_of?(StringIO) || training_data.instance_of?(File)
202
189
  training_data = training_data.respond_to?(:to_json) ? StringIO.new(training_data.to_json) : StringIO.new(training_data)
@@ -205,6 +192,7 @@ module IBMWatson
205
192
 
206
193
  method_url = "/v1/classifiers"
207
194
 
195
+ headers = authenticator.authenticate(headers)
208
196
  response = request(
209
197
  method: "POST",
210
198
  url: method_url,
@@ -228,6 +216,7 @@ module IBMWatson
228
216
 
229
217
  method_url = "/v1/classifiers"
230
218
 
219
+ headers = authenticator.authenticate(headers)
231
220
  response = request(
232
221
  method: "GET",
233
222
  url: method_url,
@@ -253,6 +242,7 @@ module IBMWatson
253
242
 
254
243
  method_url = "/v1/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
255
244
 
245
+ headers = authenticator.authenticate(headers)
256
246
  response = request(
257
247
  method: "GET",
258
248
  url: method_url,
@@ -277,6 +267,7 @@ module IBMWatson
277
267
 
278
268
  method_url = "/v1/classifiers/%s" % [ERB::Util.url_encode(classifier_id)]
279
269
 
270
+ headers = authenticator.authenticate(headers)
280
271
  request(
281
272
  method: "DELETE",
282
273
  url: method_url,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 IBM All Rights Reserved.
3
+ # (C) Copyright IBM Corp. 2019.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -88,21 +88,14 @@ module IBMWatson
88
88
  defaults = {}
89
89
  defaults[:version] = nil
90
90
  defaults[:url] = "https://gateway.watsonplatform.net/natural-language-understanding/api"
91
- defaults[:username] = nil
92
- defaults[:password] = nil
93
- defaults[:iam_apikey] = nil
94
- defaults[:iam_access_token] = nil
95
- defaults[:iam_url] = nil
96
- defaults[:iam_client_id] = nil
97
- defaults[:iam_client_secret] = nil
98
- defaults[:icp4d_access_token] = nil
99
- defaults[:icp4d_url] = nil
91
+ defaults[:authenticator] = nil
100
92
  defaults[:authentication_type] = nil
101
93
  args = defaults.merge(args)
102
- args[:vcap_services_name] = "natural-language-understanding"
94
+ @version = args[:version]
95
+ raise ArgumentError.new("version must be provided") if @version.nil?
96
+
103
97
  args[:display_name] = "Natural Language Understanding"
104
98
  super
105
- @version = args[:version]
106
99
  end
107
100
 
108
101
  #########################
@@ -175,6 +168,7 @@ module IBMWatson
175
168
 
176
169
  method_url = "/v1/analyze"
177
170
 
171
+ headers = authenticator.authenticate(headers)
178
172
  response = request(
179
173
  method: "POST",
180
174
  url: method_url,
@@ -208,6 +202,7 @@ module IBMWatson
208
202
 
209
203
  method_url = "/v1/models"
210
204
 
205
+ headers = authenticator.authenticate(headers)
211
206
  response = request(
212
207
  method: "GET",
213
208
  url: method_url,
@@ -238,6 +233,7 @@ module IBMWatson
238
233
 
239
234
  method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
240
235
 
236
+ headers = authenticator.authenticate(headers)
241
237
  response = request(
242
238
  method: "DELETE",
243
239
  url: method_url,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 IBM All Rights Reserved.
3
+ # (C) Copyright IBM Corp. 2019.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -86,12 +86,6 @@ module IBMWatson
86
86
  # 'https://iam.cloud.ibm.com/identity/token'.
87
87
  # @option args iam_client_id [String] An optional client id for the IAM service API.
88
88
  # @option args iam_client_secret [String] An optional client secret for the IAM service API.
89
- # @option args icp4d_access_token [STRING] A ICP4D(IBM Cloud Pak for Data) access token is
90
- # fully managed by the application. Responsibility falls on the application to
91
- # refresh the token, either before it expires or reactively upon receiving a 401
92
- # from the service as any requests made with an expired token will fail.
93
- # @option args icp4d_url [STRING] In order to use an SDK-managed token with ICP4D authentication, this
94
- # URL must be passed in.
95
89
  # @option args authentication_type [STRING] Specifies the authentication pattern to use. Values that it
96
90
  # takes are basic, iam or icp4d.
97
91
  def initialize(args = {})
@@ -99,21 +93,14 @@ module IBMWatson
99
93
  defaults = {}
100
94
  defaults[:version] = nil
101
95
  defaults[:url] = "https://gateway.watsonplatform.net/personality-insights/api"
102
- defaults[:username] = nil
103
- defaults[:password] = nil
104
- defaults[:iam_apikey] = nil
105
- defaults[:iam_access_token] = nil
106
- defaults[:iam_url] = nil
107
- defaults[:iam_client_id] = nil
108
- defaults[:iam_client_secret] = nil
109
- defaults[:icp4d_access_token] = nil
110
- defaults[:icp4d_url] = nil
96
+ defaults[:authenticator] = nil
111
97
  defaults[:authentication_type] = nil
112
98
  args = defaults.merge(args)
113
- args[:vcap_services_name] = "personality_insights"
99
+ @version = args[:version]
100
+ raise ArgumentError.new("version must be provided") if @version.nil?
101
+
114
102
  args[:display_name] = "Personality Insights"
115
103
  super
116
- @version = args[:version]
117
104
  end
118
105
 
119
106
  #########################
@@ -121,7 +108,7 @@ module IBMWatson
121
108
  #########################
122
109
 
123
110
  ##
124
- # @!method profile(content:, accept:, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil, content_type: nil)
111
+ # @!method profile(content:, accept:, content_type: nil, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil)
125
112
  # Get profile.
126
113
  # Generates a personality profile for the author of the input text. The service
127
114
  # accepts a maximum of 20 MB of input content, but it requires much less text to
@@ -172,6 +159,8 @@ module IBMWatson
172
159
  # For JSON input, provide an object of type `Content`.
173
160
  # @param accept [String] The type of the response. For more information, see **Accept types** in the method
174
161
  # description.
162
+ # @param content_type [String] The type of the input. For more information, see **Content types** in the method
163
+ # description.
175
164
  # @param content_language [String] The language of the input text for the request: Arabic, English, Japanese, Korean,
176
165
  # or Spanish. Regional variants are treated as their parent language; for example,
177
166
  # `en-US` is interpreted as `en`.
@@ -196,19 +185,17 @@ module IBMWatson
196
185
  # (`text/csv`).
197
186
  # @param consumption_preferences [Boolean] Indicates whether consumption preferences are returned with the results. By
198
187
  # default, no consumption preferences are returned.
199
- # @param content_type [String] The type of the input. For more information, see **Content types** in the method
200
- # description.
201
188
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
202
- def profile(content:, accept:, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil, content_type: nil)
189
+ def profile(content:, accept:, content_type: nil, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil)
203
190
  raise ArgumentError.new("content must be provided") if content.nil?
204
191
 
205
192
  raise ArgumentError.new("accept must be provided") if accept.nil?
206
193
 
207
194
  headers = {
208
195
  "Accept" => accept,
196
+ "Content-Type" => content_type,
209
197
  "Content-Language" => content_language,
210
- "Accept-Language" => accept_language,
211
- "Content-Type" => content_type
198
+ "Accept-Language" => accept_language
212
199
  }
213
200
  sdk_headers = Common.new.get_sdk_headers("personality_insights", "V3", "profile")
214
201
  headers.merge!(sdk_headers)
@@ -228,6 +215,7 @@ module IBMWatson
228
215
 
229
216
  method_url = "/v3/profile"
230
217
 
218
+ headers = authenticator.authenticate(headers)
231
219
  response = request(
232
220
  method: "POST",
233
221
  url: method_url,
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright 2018 IBM All Rights Reserved.
3
+ # (C) Copyright IBM Corp. 2019.
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -91,18 +91,9 @@ module IBMWatson
91
91
  @__async_initialized__ = false
92
92
  defaults = {}
93
93
  defaults[:url] = "https://stream.watsonplatform.net/speech-to-text/api"
94
- defaults[:username] = nil
95
- defaults[:password] = nil
96
- defaults[:iam_apikey] = nil
97
- defaults[:iam_access_token] = nil
98
- defaults[:iam_url] = nil
99
- defaults[:iam_client_id] = nil
100
- defaults[:iam_client_secret] = nil
101
- defaults[:icp4d_access_token] = nil
102
- defaults[:icp4d_url] = nil
94
+ defaults[:authenticator] = nil
103
95
  defaults[:authentication_type] = nil
104
96
  args = defaults.merge(args)
105
- args[:vcap_services_name] = "speech_to_text"
106
97
  args[:display_name] = "Speech to Text"
107
98
  super
108
99
  end
@@ -129,6 +120,7 @@ module IBMWatson
129
120
 
130
121
  method_url = "/v1/models"
131
122
 
123
+ headers = authenticator.authenticate(headers)
132
124
  response = request(
133
125
  method: "GET",
134
126
  url: method_url,
@@ -160,6 +152,7 @@ module IBMWatson
160
152
 
161
153
  method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
162
154
 
155
+ headers = authenticator.authenticate(headers)
163
156
  response = request(
164
157
  method: "GET",
165
158
  url: method_url,
@@ -173,7 +166,7 @@ module IBMWatson
173
166
  #########################
174
167
 
175
168
  ##
176
- # @!method recognize(audio:, model: nil, language_customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil, customization_id: nil, grammar_name: nil, redaction: nil, audio_metrics: nil, content_type: nil)
169
+ # @!method recognize(audio:, content_type: nil, model: nil, language_customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil, customization_id: nil, grammar_name: nil, redaction: nil, audio_metrics: nil)
177
170
  # Recognize audio.
178
171
  # Sends audio and returns transcription results for a recognition request. You can
179
172
  # pass a maximum of 100 MB and a minimum of 100 bytes of audio with a request. The
@@ -212,7 +205,7 @@ module IBMWatson
212
205
  # * For all other formats, you can omit the `Content-Type` header or specify
213
206
  # `application/octet-stream` with the header to have the service automatically
214
207
  # detect the format of the audio. (With the `curl` command, you can specify either
215
- # `\"Content-Type:\"` or `\"Content-Type: application/octet-stream\"`.)
208
+ # `"Content-Type:"` or `"Content-Type: application/octet-stream"`.)
216
209
  #
217
210
  # Where indicated, the format that you specify must include the sampling rate and
218
211
  # can optionally include the number of channels and the endianness of the audio.
@@ -262,6 +255,8 @@ module IBMWatson
262
255
  # **See also:** [Making a multipart HTTP
263
256
  # request](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-http#HTTP-multi).
264
257
  # @param audio [String] The audio to transcribe.
258
+ # @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
259
+ # audio format, see **Audio formats (content types)** in the method description.
265
260
  # @param model [String] The identifier of the model that is to be used for the recognition request. See
266
261
  # [Languages and
267
262
  # models](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-models#models).
@@ -327,7 +322,7 @@ module IBMWatson
327
322
  # the service uses the default value, `1`. See [Maximum
328
323
  # alternatives](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-output#max_alternatives).
329
324
  # @param word_alternatives_threshold [Float] A confidence value that is the lower bound for identifying a hypothesis as a
330
- # possible word alternative (also known as \"Confusion Networks\"). An alternative
325
+ # possible word alternative (also known as "Confusion Networks"). An alternative
331
326
  # word is considered if its confidence is greater than or equal to the threshold.
332
327
  # Specify a probability between 0.0 and 1.0. By default, the service computes no
333
328
  # alternative words. See [Word
@@ -359,7 +354,8 @@ module IBMWatson
359
354
  # parameter to be `true`, regardless of whether you specify `false` for the
360
355
  # parameter.
361
356
  #
362
- # **Note:** Applies to US English, Japanese, and Spanish transcription only. To
357
+ # **Note:** Applies to US English, Japanese, and Spanish (both broadband and
358
+ # narrowband models) and UK English (narrowband model) transcription only. To
363
359
  # determine whether a language model supports speaker labels, you can also use the
364
360
  # **Get a model** method and check that the attribute `speaker_labels` is set to
365
361
  # `true`.
@@ -393,10 +389,8 @@ module IBMWatson
393
389
  # @param audio_metrics [Boolean] If `true`, requests detailed information about the signal characteristics of the
394
390
  # input audio. The service returns audio metrics with the final transcription
395
391
  # results. By default, the service returns no audio metrics.
396
- # @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
397
- # audio format, see **Audio formats (content types)** in the method description.
398
392
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
399
- def recognize(audio:, model: nil, language_customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil, customization_id: nil, grammar_name: nil, redaction: nil, audio_metrics: nil, content_type: nil)
393
+ def recognize(audio:, content_type: nil, model: nil, language_customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil, customization_id: nil, grammar_name: nil, redaction: nil, audio_metrics: nil)
400
394
  raise ArgumentError.new("audio must be provided") if audio.nil?
401
395
 
402
396
  headers = {
@@ -432,6 +426,7 @@ module IBMWatson
432
426
 
433
427
  method_url = "/v1/recognize"
434
428
 
429
+ headers = authenticator.authenticate(headers)
435
430
  response = request(
436
431
  method: "POST",
437
432
  url: method_url,
@@ -541,12 +536,7 @@ module IBMWatson
541
536
  require_relative("./websocket/speech_to_text_websocket_listener.rb")
542
537
  headers = {}
543
538
  headers = conn.default_options.headers.to_hash unless conn.default_options.headers.to_hash.empty?
544
- if !token_manager.nil?
545
- access_token = token_manager.token
546
- headers["Authorization"] = "Bearer #{access_token}"
547
- elsif !username.nil? && !password.nil?
548
- headers["Authorization"] = "Basic " + Base64.strict_encode64("#{username}:#{password}")
549
- end
539
+ headers = authenticator.authenticate(headers)
550
540
  url = @url.gsub("https:", "wss:")
551
541
  params = {
552
542
  "model" => model,
@@ -697,6 +687,7 @@ module IBMWatson
697
687
 
698
688
  method_url = "/v1/register_callback"
699
689
 
690
+ headers = authenticator.authenticate(headers)
700
691
  response = request(
701
692
  method: "POST",
702
693
  url: method_url,
@@ -732,6 +723,7 @@ module IBMWatson
732
723
 
733
724
  method_url = "/v1/unregister_callback"
734
725
 
726
+ headers = authenticator.authenticate(headers)
735
727
  request(
736
728
  method: "POST",
737
729
  url: method_url,
@@ -743,7 +735,7 @@ module IBMWatson
743
735
  end
744
736
 
745
737
  ##
746
- # @!method create_job(audio:, model: nil, callback_url: nil, events: nil, user_token: nil, results_ttl: nil, language_customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil, customization_id: nil, grammar_name: nil, redaction: nil, audio_metrics: nil, content_type: nil)
738
+ # @!method create_job(audio:, content_type: nil, model: nil, callback_url: nil, events: nil, user_token: nil, results_ttl: nil, language_customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil, customization_id: nil, grammar_name: nil, redaction: nil, processing_metrics: nil, processing_metrics_interval: nil, audio_metrics: nil)
747
739
  # Create a job.
748
740
  # Creates a job for a new asynchronous recognition request. The job is owned by the
749
741
  # instance of the service whose credentials are used to create it. How you learn the
@@ -811,7 +803,7 @@ module IBMWatson
811
803
  # * For all other formats, you can omit the `Content-Type` header or specify
812
804
  # `application/octet-stream` with the header to have the service automatically
813
805
  # detect the format of the audio. (With the `curl` command, you can specify either
814
- # `\"Content-Type:\"` or `\"Content-Type: application/octet-stream\"`.)
806
+ # `"Content-Type:"` or `"Content-Type: application/octet-stream"`.)
815
807
  #
816
808
  # Where indicated, the format that you specify must include the sampling rate and
817
809
  # can optionally include the number of channels and the endianness of the audio.
@@ -842,6 +834,8 @@ module IBMWatson
842
834
  # **See also:** [Audio
843
835
  # formats](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-audio-formats#audio-formats).
844
836
  # @param audio [String] The audio to transcribe.
837
+ # @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
838
+ # audio format, see **Audio formats (content types)** in the method description.
845
839
  # @param model [String] The identifier of the model that is to be used for the recognition request. See
846
840
  # [Languages and
847
841
  # models](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-models#models).
@@ -941,7 +935,7 @@ module IBMWatson
941
935
  # the service uses the default value, `1`. See [Maximum
942
936
  # alternatives](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-output#max_alternatives).
943
937
  # @param word_alternatives_threshold [Float] A confidence value that is the lower bound for identifying a hypothesis as a
944
- # possible word alternative (also known as \"Confusion Networks\"). An alternative
938
+ # possible word alternative (also known as "Confusion Networks"). An alternative
945
939
  # word is considered if its confidence is greater than or equal to the threshold.
946
940
  # Specify a probability between 0.0 and 1.0. By default, the service computes no
947
941
  # alternative words. See [Word
@@ -973,7 +967,8 @@ module IBMWatson
973
967
  # parameter to be `true`, regardless of whether you specify `false` for the
974
968
  # parameter.
975
969
  #
976
- # **Note:** Applies to US English, Japanese, and Spanish transcription only. To
970
+ # **Note:** Applies to US English, Japanese, and Spanish (both broadband and
971
+ # narrowband models) and UK English (narrowband model) transcription only. To
977
972
  # determine whether a language model supports speaker labels, you can also use the
978
973
  # **Get a model** method and check that the attribute `speaker_labels` is set to
979
974
  # `true`.
@@ -1004,7 +999,6 @@ module IBMWatson
1004
999
  #
1005
1000
  # See [Numeric
1006
1001
  # redaction](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-output#redaction).
1007
- #
1008
1002
  # @param processing_metrics [Boolean] If `true`, requests processing metrics about the service's transcription of the
1009
1003
  # input audio. The service returns processing metrics at the interval specified by
1010
1004
  # the `processing_metrics_interval` parameter. It also returns processing metrics
@@ -1012,7 +1006,7 @@ module IBMWatson
1012
1006
  # the service returns no processing metrics.
1013
1007
  # @param processing_metrics_interval [Float] Specifies the interval in real wall-clock seconds at which the service is to
1014
1008
  # return processing metrics. The parameter is ignored unless the
1015
- # `processing_metrics` parameter is set to `true`. # The parameter accepts a minimum value of 0.1 seconds. The level of precision is
1009
+ # `processing_metrics` parameter is set to `true`.
1016
1010
  #
1017
1011
  # The parameter accepts a minimum value of 0.1 seconds. The level of precision is
1018
1012
  # not restricted, so you can specify values such as 0.25 and 0.125.
@@ -1024,10 +1018,8 @@ module IBMWatson
1024
1018
  # @param audio_metrics [Boolean] If `true`, requests detailed information about the signal characteristics of the
1025
1019
  # input audio. The service returns audio metrics with the final transcription
1026
1020
  # results. By default, the service returns no audio metrics.
1027
- # @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
1028
- # audio format, see **Audio formats (content types)** in the method description.
1029
1021
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
1030
- def create_job(audio:, model: nil, callback_url: nil, events: nil, user_token: nil, results_ttl: nil, language_customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil, customization_id: nil, grammar_name: nil, redaction: nil, processing_metrics: nil, processing_metrics_interval: nil, audio_metrics: nil, content_type: nil)
1022
+ def create_job(audio:, content_type: nil, model: nil, callback_url: nil, events: nil, user_token: nil, results_ttl: nil, language_customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil, customization_id: nil, grammar_name: nil, redaction: nil, processing_metrics: nil, processing_metrics_interval: nil, audio_metrics: nil)
1031
1023
  raise ArgumentError.new("audio must be provided") if audio.nil?
1032
1024
 
1033
1025
  headers = {
@@ -1068,6 +1060,7 @@ module IBMWatson
1068
1060
 
1069
1061
  method_url = "/v1/recognitions"
1070
1062
 
1063
+ headers = authenticator.authenticate(headers)
1071
1064
  response = request(
1072
1065
  method: "POST",
1073
1066
  url: method_url,
@@ -1102,6 +1095,7 @@ module IBMWatson
1102
1095
 
1103
1096
  method_url = "/v1/recognitions"
1104
1097
 
1098
+ headers = authenticator.authenticate(headers)
1105
1099
  response = request(
1106
1100
  method: "GET",
1107
1101
  url: method_url,
@@ -1142,6 +1136,7 @@ module IBMWatson
1142
1136
 
1143
1137
  method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
1144
1138
 
1139
+ headers = authenticator.authenticate(headers)
1145
1140
  response = request(
1146
1141
  method: "GET",
1147
1142
  url: method_url,
@@ -1176,6 +1171,7 @@ module IBMWatson
1176
1171
 
1177
1172
  method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
1178
1173
 
1174
+ headers = authenticator.authenticate(headers)
1179
1175
  request(
1180
1176
  method: "DELETE",
1181
1177
  url: method_url,
@@ -1211,16 +1207,24 @@ module IBMWatson
1211
1207
  # to `true`. You can also refer to [Language support for
1212
1208
  # customization](https://cloud.ibm.com/docs/services/speech-to-text?topic=speech-to-text-customization#languageSupport).
1213
1209
  # @param dialect [String] The dialect of the specified language that is to be used with the custom language
1214
- # model. The parameter is meaningful only for Spanish models, for which the service
1215
- # creates a custom language model that is suited for speech in one of the following
1216
- # dialects:
1217
- # * `es-ES` for Castilian Spanish (the default)
1218
- # * `es-LA` for Latin American Spanish
1219
- # * `es-US` for North American (Mexican) Spanish
1220
- #
1221
- # A specified dialect must be valid for the base model. By default, the dialect
1222
- # matches the language of the base model; for example, `en-US` for either of the US
1223
- # English language models.
1210
+ # model. For most languages, the dialect matches the language of the base model by
1211
+ # default. For example, `en-US` is used for either of the US English language
1212
+ # models.
1213
+ #
1214
+ # For a Spanish language, the service creates a custom language model that is suited
1215
+ # for speech in one of the following dialects:
1216
+ # * `es-ES` for Castilian Spanish (`es-ES` models)
1217
+ # * `es-LA` for Latin American Spanish (`es-AR`, `es-CL`, `es-CO`, and `es-PE`
1218
+ # models)
1219
+ # * `es-US` for Mexican (North American) Spanish (`es-MX` models)
1220
+ #
1221
+ # The parameter is meaningful only for Spanish models, for which you can always
1222
+ # safely omit the parameter to have the service create the correct mapping.
1223
+ #
1224
+ # If you specify the `dialect` parameter for non-Spanish language models, its value
1225
+ # must match the language of the base model. If you specify the `dialect` for
1226
+ # Spanish language models, its value must match one of the defined mappings as
1227
+ # indicated (`es-ES`, `es-LA`, or `es-MX`). All dialect values are case-insensitive.
1224
1228
  # @param description [String] A description of the new custom language model. Use a localized description that
1225
1229
  # matches the language of the custom model.
1226
1230
  # @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
@@ -1243,6 +1247,7 @@ module IBMWatson
1243
1247
 
1244
1248
  method_url = "/v1/customizations"
1245
1249
 
1250
+ headers = authenticator.authenticate(headers)
1246
1251
  response = request(
1247
1252
  method: "POST",
1248
1253
  url: method_url,
@@ -1280,6 +1285,7 @@ module IBMWatson
1280
1285
 
1281
1286
  method_url = "/v1/customizations"
1282
1287
 
1288
+ headers = authenticator.authenticate(headers)
1283
1289
  response = request(
1284
1290
  method: "GET",
1285
1291
  url: method_url,
@@ -1312,6 +1318,7 @@ module IBMWatson
1312
1318
 
1313
1319
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
1314
1320
 
1321
+ headers = authenticator.authenticate(headers)
1315
1322
  response = request(
1316
1323
  method: "GET",
1317
1324
  url: method_url,
@@ -1345,6 +1352,7 @@ module IBMWatson
1345
1352
 
1346
1353
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
1347
1354
 
1355
+ headers = authenticator.authenticate(headers)
1348
1356
  request(
1349
1357
  method: "DELETE",
1350
1358
  url: method_url,
@@ -1433,6 +1441,7 @@ module IBMWatson
1433
1441
 
1434
1442
  method_url = "/v1/customizations/%s/train" % [ERB::Util.url_encode(customization_id)]
1435
1443
 
1444
+ headers = authenticator.authenticate(headers)
1436
1445
  response = request(
1437
1446
  method: "POST",
1438
1447
  url: method_url,
@@ -1469,6 +1478,7 @@ module IBMWatson
1469
1478
 
1470
1479
  method_url = "/v1/customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
1471
1480
 
1481
+ headers = authenticator.authenticate(headers)
1472
1482
  request(
1473
1483
  method: "POST",
1474
1484
  url: method_url,
@@ -1513,6 +1523,7 @@ module IBMWatson
1513
1523
 
1514
1524
  method_url = "/v1/customizations/%s/upgrade_model" % [ERB::Util.url_encode(customization_id)]
1515
1525
 
1526
+ headers = authenticator.authenticate(headers)
1516
1527
  request(
1517
1528
  method: "POST",
1518
1529
  url: method_url,
@@ -1549,6 +1560,7 @@ module IBMWatson
1549
1560
 
1550
1561
  method_url = "/v1/customizations/%s/corpora" % [ERB::Util.url_encode(customization_id)]
1551
1562
 
1563
+ headers = authenticator.authenticate(headers)
1552
1564
  response = request(
1553
1565
  method: "GET",
1554
1566
  url: method_url,
@@ -1665,6 +1677,7 @@ module IBMWatson
1665
1677
 
1666
1678
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1667
1679
 
1680
+ headers = authenticator.authenticate(headers)
1668
1681
  request(
1669
1682
  method: "POST",
1670
1683
  url: method_url,
@@ -1703,6 +1716,7 @@ module IBMWatson
1703
1716
 
1704
1717
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1705
1718
 
1719
+ headers = authenticator.authenticate(headers)
1706
1720
  response = request(
1707
1721
  method: "GET",
1708
1722
  url: method_url,
@@ -1743,6 +1757,7 @@ module IBMWatson
1743
1757
 
1744
1758
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1745
1759
 
1760
+ headers = authenticator.authenticate(headers)
1746
1761
  request(
1747
1762
  method: "DELETE",
1748
1763
  url: method_url,
@@ -1799,6 +1814,7 @@ module IBMWatson
1799
1814
 
1800
1815
  method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
1801
1816
 
1817
+ headers = authenticator.authenticate(headers)
1802
1818
  response = request(
1803
1819
  method: "GET",
1804
1820
  url: method_url,
@@ -1890,6 +1906,7 @@ module IBMWatson
1890
1906
 
1891
1907
  method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
1892
1908
 
1909
+ headers = authenticator.authenticate(headers)
1893
1910
  request(
1894
1911
  method: "POST",
1895
1912
  url: method_url,
@@ -1986,6 +2003,7 @@ module IBMWatson
1986
2003
 
1987
2004
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
1988
2005
 
2006
+ headers = authenticator.authenticate(headers)
1989
2007
  request(
1990
2008
  method: "PUT",
1991
2009
  url: method_url,
@@ -2024,6 +2042,7 @@ module IBMWatson
2024
2042
 
2025
2043
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
2026
2044
 
2045
+ headers = authenticator.authenticate(headers)
2027
2046
  response = request(
2028
2047
  method: "GET",
2029
2048
  url: method_url,
@@ -2065,6 +2084,7 @@ module IBMWatson
2065
2084
 
2066
2085
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
2067
2086
 
2087
+ headers = authenticator.authenticate(headers)
2068
2088
  request(
2069
2089
  method: "DELETE",
2070
2090
  url: method_url,
@@ -2101,6 +2121,7 @@ module IBMWatson
2101
2121
 
2102
2122
  method_url = "/v1/customizations/%s/grammars" % [ERB::Util.url_encode(customization_id)]
2103
2123
 
2124
+ headers = authenticator.authenticate(headers)
2104
2125
  response = request(
2105
2126
  method: "GET",
2106
2127
  url: method_url,
@@ -2212,6 +2233,7 @@ module IBMWatson
2212
2233
 
2213
2234
  method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]
2214
2235
 
2236
+ headers = authenticator.authenticate(headers)
2215
2237
  request(
2216
2238
  method: "POST",
2217
2239
  url: method_url,
@@ -2250,6 +2272,7 @@ module IBMWatson
2250
2272
 
2251
2273
  method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]
2252
2274
 
2275
+ headers = authenticator.authenticate(headers)
2253
2276
  response = request(
2254
2277
  method: "GET",
2255
2278
  url: method_url,
@@ -2289,6 +2312,7 @@ module IBMWatson
2289
2312
 
2290
2313
  method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]
2291
2314
 
2315
+ headers = authenticator.authenticate(headers)
2292
2316
  request(
2293
2317
  method: "DELETE",
2294
2318
  url: method_url,
@@ -2344,6 +2368,7 @@ module IBMWatson
2344
2368
 
2345
2369
  method_url = "/v1/acoustic_customizations"
2346
2370
 
2371
+ headers = authenticator.authenticate(headers)
2347
2372
  response = request(
2348
2373
  method: "POST",
2349
2374
  url: method_url,
@@ -2381,6 +2406,7 @@ module IBMWatson
2381
2406
 
2382
2407
  method_url = "/v1/acoustic_customizations"
2383
2408
 
2409
+ headers = authenticator.authenticate(headers)
2384
2410
  response = request(
2385
2411
  method: "GET",
2386
2412
  url: method_url,
@@ -2413,6 +2439,7 @@ module IBMWatson
2413
2439
 
2414
2440
  method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
2415
2441
 
2442
+ headers = authenticator.authenticate(headers)
2416
2443
  response = request(
2417
2444
  method: "GET",
2418
2445
  url: method_url,
@@ -2446,6 +2473,7 @@ module IBMWatson
2446
2473
 
2447
2474
  method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
2448
2475
 
2476
+ headers = authenticator.authenticate(headers)
2449
2477
  request(
2450
2478
  method: "DELETE",
2451
2479
  url: method_url,
@@ -2537,6 +2565,7 @@ module IBMWatson
2537
2565
 
2538
2566
  method_url = "/v1/acoustic_customizations/%s/train" % [ERB::Util.url_encode(customization_id)]
2539
2567
 
2568
+ headers = authenticator.authenticate(headers)
2540
2569
  response = request(
2541
2570
  method: "POST",
2542
2571
  url: method_url,
@@ -2575,6 +2604,7 @@ module IBMWatson
2575
2604
 
2576
2605
  method_url = "/v1/acoustic_customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
2577
2606
 
2607
+ headers = authenticator.authenticate(headers)
2578
2608
  request(
2579
2609
  method: "POST",
2580
2610
  url: method_url,
@@ -2643,6 +2673,7 @@ module IBMWatson
2643
2673
 
2644
2674
  method_url = "/v1/acoustic_customizations/%s/upgrade_model" % [ERB::Util.url_encode(customization_id)]
2645
2675
 
2676
+ headers = authenticator.authenticate(headers)
2646
2677
  request(
2647
2678
  method: "POST",
2648
2679
  url: method_url,
@@ -2682,6 +2713,7 @@ module IBMWatson
2682
2713
 
2683
2714
  method_url = "/v1/acoustic_customizations/%s/audio" % [ERB::Util.url_encode(customization_id)]
2684
2715
 
2716
+ headers = authenticator.authenticate(headers)
2685
2717
  response = request(
2686
2718
  method: "GET",
2687
2719
  url: method_url,
@@ -2692,7 +2724,7 @@ module IBMWatson
2692
2724
  end
2693
2725
 
2694
2726
  ##
2695
- # @!method add_audio(customization_id:, audio_name:, audio_resource:, contained_content_type: nil, allow_overwrite: nil, content_type: nil)
2727
+ # @!method add_audio(customization_id:, audio_name:, audio_resource:, content_type: nil, contained_content_type: nil, allow_overwrite: nil)
2696
2728
  # Add an audio resource.
2697
2729
  # Adds an audio resource to a custom acoustic model. Add audio content that reflects
2698
2730
  # the acoustic characteristics of the audio that you plan to transcribe. You must
@@ -2816,6 +2848,13 @@ module IBMWatson
2816
2848
  #
2817
2849
  # With the `curl` command, use the `--data-binary` option to upload the file for the
2818
2850
  # request.
2851
+ # @param content_type [String] For an audio-type resource, the format (MIME type) of the audio. For more
2852
+ # information, see **Content types for audio-type resources** in the method
2853
+ # description.
2854
+ #
2855
+ # For an archive-type resource, the media type of the archive file. For more
2856
+ # information, see **Content types for archive-type resources** in the method
2857
+ # description.
2819
2858
  # @param contained_content_type [String] **For an archive-type resource,** specify the format of the audio files that are
2820
2859
  # contained in the archive file if they are of type `audio/alaw`, `audio/basic`,
2821
2860
  # `audio/l16`, or `audio/mulaw`. Include the `rate`, `channels`, and `endianness`
@@ -2835,15 +2874,8 @@ module IBMWatson
2835
2874
  # the same name. If `false`, the request fails if an audio resource with the same
2836
2875
  # name already exists. The parameter has no effect if an audio resource with the
2837
2876
  # same name does not already exist.
2838
- # @param content_type [String] For an audio-type resource, the format (MIME type) of the audio. For more
2839
- # information, see **Content types for audio-type resources** in the method
2840
- # description.
2841
- #
2842
- # For an archive-type resource, the media type of the archive file. For more
2843
- # information, see **Content types for archive-type resources** in the method
2844
- # description.
2845
2877
  # @return [nil]
2846
- def add_audio(customization_id:, audio_name:, audio_resource:, contained_content_type: nil, allow_overwrite: nil, content_type: nil)
2878
+ def add_audio(customization_id:, audio_name:, audio_resource:, content_type: nil, contained_content_type: nil, allow_overwrite: nil)
2847
2879
  raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
2848
2880
 
2849
2881
  raise ArgumentError.new("audio_name must be provided") if audio_name.nil?
@@ -2851,8 +2883,8 @@ module IBMWatson
2851
2883
  raise ArgumentError.new("audio_resource must be provided") if audio_resource.nil?
2852
2884
 
2853
2885
  headers = {
2854
- "Contained-Content-Type" => contained_content_type,
2855
- "Content-Type" => content_type
2886
+ "Content-Type" => content_type,
2887
+ "Contained-Content-Type" => contained_content_type
2856
2888
  }
2857
2889
  sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "add_audio")
2858
2890
  headers.merge!(sdk_headers)
@@ -2865,6 +2897,7 @@ module IBMWatson
2865
2897
 
2866
2898
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2867
2899
 
2900
+ headers = authenticator.authenticate(headers)
2868
2901
  request(
2869
2902
  method: "POST",
2870
2903
  url: method_url,
@@ -2919,6 +2952,7 @@ module IBMWatson
2919
2952
 
2920
2953
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2921
2954
 
2955
+ headers = authenticator.authenticate(headers)
2922
2956
  response = request(
2923
2957
  method: "GET",
2924
2958
  url: method_url,
@@ -2960,6 +2994,7 @@ module IBMWatson
2960
2994
 
2961
2995
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2962
2996
 
2997
+ headers = authenticator.authenticate(headers)
2963
2998
  request(
2964
2999
  method: "DELETE",
2965
3000
  url: method_url,
@@ -3002,6 +3037,7 @@ module IBMWatson
3002
3037
 
3003
3038
  method_url = "/v1/user_data"
3004
3039
 
3040
+ headers = authenticator.authenticate(headers)
3005
3041
  request(
3006
3042
  method: "DELETE",
3007
3043
  url: method_url,