ibm_watson 0.9.2 → 0.10.0

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.
@@ -30,10 +30,9 @@
30
30
  # * For information about the meaning of the consumption preferences, see [Consumption
31
31
  # preferences](https://console.bluemix.net/docs/services/personality-insights/preferences.html).
32
32
  #
33
- #
34
- # **Note:** Request logging is disabled for the Personality Insights service. The service
35
- # neither logs nor retains data from requests and responses, regardless of whether the
36
- # `X-Watson-Learning-Opt-Out` request header is set.
33
+ # **Note:** Request logging is disabled for the Personality Insights service. Regardless
34
+ # of whether you set the `X-Watson-Learning-Opt-Out` request header, the service does not
35
+ # log or retain data from requests and responses.
37
36
 
38
37
  require "concurrent"
39
38
  require "erb"
@@ -106,42 +105,57 @@ module IBMWatson
106
105
  #########################
107
106
 
108
107
  ##
109
- # @!method profile(content:, content_type:, accept: nil, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil)
108
+ # @!method profile(content:, accept:, content_type: nil, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil)
110
109
  # Get profile.
111
110
  # Generates a personality profile for the author of the input text. The service
112
111
  # accepts a maximum of 20 MB of input content, but it requires much less text to
113
- # produce an accurate profile; for more information, see [Providing sufficient
114
- # input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient).
115
- # The service analyzes text in Arabic, English, Japanese, Korean, or Spanish and
116
- # returns its results in a variety of languages. You can provide plain text, HTML,
117
- # or JSON input by specifying the **Content-Type** parameter; the default is
118
- # `text/plain`. Request a JSON or comma-separated values (CSV) response by
119
- # specifying the **Accept** parameter; CSV output includes a fixed number of columns
120
- # and optional headers.
112
+ # produce an accurate profile. The service can analyze text in Arabic, English,
113
+ # Japanese, Korean, or Spanish. It can return its results in a variety of languages.
114
+ #
115
+ #
116
+ # **See also:**
117
+ # * [Requesting a profile](https://console.bluemix.net/docs/services/personality-insights/input.html)
118
+ # * [Providing sufficient
119
+ # input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient)
120
+ #
121
+ # ### Content types
122
+ #
123
+ # You can provide input content as plain text (`text/plain`), HTML (`text/html`),
124
+ # or JSON (`application/json`) by specifying the **Content-Type** parameter. The
125
+ # default is `text/plain`.
126
+ # * Per the JSON specification, the default character encoding for JSON content is
127
+ # effectively always UTF-8.
128
+ # * Per the HTTP specification, the default encoding for plain text and HTML is
129
+ # ISO-8859-1 (effectively, the ASCII character set).
130
+ #
131
+ # When specifying a content type of plain text or HTML, include the `charset`
132
+ # parameter to indicate the character encoding of the input text; for example,
133
+ # `Content-Type: text/plain;charset=utf-8`.
134
+ #
135
+ # **See also:** [Specifying request and response
136
+ # formats](https://console.bluemix.net/docs/services/personality-insights/input.html#formats)
121
137
  #
122
- # Per the JSON specification, the default character encoding for JSON content is
123
- # effectively always UTF-8; per the HTTP specification, the default encoding for
124
- # plain text and HTML is ISO-8859-1 (effectively, the ASCII character set). When
125
- # specifying a content type of plain text or HTML, include the `charset` parameter
126
- # to indicate the character encoding of the input text; for example: `Content-Type:
127
- # text/plain;charset=utf-8`.
138
+ # ### Accept types
139
+ #
140
+ # You must request a response as JSON (`application/json`) or comma-separated
141
+ # values (`text/csv`) by specifying the **Accept** parameter. CSV output includes a
142
+ # fixed number of columns. Set the **csv_headers** parameter to `true` to request
143
+ # optional column headers for CSV output.
128
144
  #
129
145
  # **See also:**
130
- # * [Requesting a
131
- # profile](https://console.bluemix.net/docs/services/personality-insights/input.html)
132
- # * [Understanding a JSON
133
- # profile](https://console.bluemix.net/docs/services/personality-insights/output.html)
146
+ # * [Understanding a JSON profile](https://console.bluemix.net/docs/services/personality-insights/output.html)
134
147
  # * [Understanding a CSV
135
148
  # profile](https://console.bluemix.net/docs/services/personality-insights/output-csv.html).
136
149
  # @param content [Content] A maximum of 20 MB of content to analyze, though the service requires much less
137
150
  # text; for more information, see [Providing sufficient
138
- # input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient).
139
- # For JSON input, provide an object of type `Content`.
140
- # @param content_type [String] The type of the input. A character encoding can be specified by including a
141
- # `charset` parameter. For example, 'text/html;charset=utf-8'.
142
- # @param accept [String] The type of the response: application/json or text/csv. A character encoding can
143
- # be specified by including a `charset` parameter. For example,
144
- # 'text/csv;charset=utf-8'.
151
+ # input](https://console.bluemix.net/docs/services/personality-insights/input.html#sufficient). For JSON input,
152
+ # provide an object of type `Content`.
153
+ # @param accept [String] The type of the response. For more information, see **Accept types** in the method
154
+ # description.
155
+ # @param content_type [String] The type of the input. For more information, see **Content types** in the method
156
+ # description.
157
+ #
158
+ # Default: `text/plain`.
145
159
  # @param content_language [String] The language of the input text for the request: Arabic, English, Japanese, Korean,
146
160
  # or Spanish. Regional variants are treated as their parent language; for example,
147
161
  # `en-US` is interpreted as `en`.
@@ -162,34 +176,38 @@ module IBMWatson
162
176
  # for each characteristic; raw scores are not compared with a sample population. By
163
177
  # default, only normalized percentiles are returned.
164
178
  # @param csv_headers [Boolean] Indicates whether column labels are returned with a CSV response. By default, no
165
- # column labels are returned. Applies only when the **Accept** parameter is set to
166
- # `text/csv`.
179
+ # column labels are returned. Applies only when the response type is CSV
180
+ # (`text/csv`).
167
181
  # @param consumption_preferences [Boolean] Indicates whether consumption preferences are returned with the results. By
168
182
  # default, no consumption preferences are returned.
169
183
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
170
- def profile(content:, content_type:, accept: nil, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil)
171
- raise ArgumentError("content must be provided") if content.nil?
184
+ def profile(content:, accept:, content_type: nil, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil)
185
+ raise ArgumentError.new("content must be provided") if content.nil?
172
186
 
173
- raise ArgumentError("content_type must be provided") if content_type.nil?
187
+ raise ArgumentError.new("accept must be provided") if accept.nil?
174
188
 
175
189
  headers = {
176
- "Content-Type" => content_type,
177
190
  "Accept" => accept,
191
+ "Content-Type" => content_type,
178
192
  "Content-Language" => content_language,
179
193
  "Accept-Language" => accept_language
180
194
  }
195
+
181
196
  params = {
182
197
  "version" => @version,
183
198
  "raw_scores" => raw_scores,
184
199
  "csv_headers" => csv_headers,
185
200
  "consumption_preferences" => consumption_preferences
186
201
  }
202
+
187
203
  if content_type.start_with?("application/json") && content.instance_of?(Hash)
188
204
  data = content.to_json
189
205
  else
190
206
  data = content
191
207
  end
208
+
192
209
  method_url = "/v3/profile"
210
+
193
211
  response = request(
194
212
  method: "POST",
195
213
  url: method_url,
@@ -105,7 +105,9 @@ module IBMWatson
105
105
  def list_models
106
106
  headers = {
107
107
  }
108
+
108
109
  method_url = "/v1/models"
110
+
109
111
  response = request(
110
112
  method: "GET",
111
113
  url: method_url,
@@ -124,15 +126,17 @@ module IBMWatson
124
126
  #
125
127
  # **See also:** [Languages and
126
128
  # models](https://console.bluemix.net/docs/services/speech-to-text/input.html#models).
127
- # @param model_id [String] The identifier of the model in the form of its name from the output of the **Get
128
- # models** method.
129
+ # @param model_id [String] The identifier of the model in the form of its name from the output of the **Get a
130
+ # model** method.
129
131
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
130
132
  def get_model(model_id:)
131
- raise ArgumentError("model_id must be provided") if model_id.nil?
133
+ raise ArgumentError.new("model_id must be provided") if model_id.nil?
132
134
 
133
135
  headers = {
134
136
  }
137
+
135
138
  method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
139
+
136
140
  response = request(
137
141
  method: "GET",
138
142
  url: method_url,
@@ -148,16 +152,16 @@ module IBMWatson
148
152
  ##
149
153
  # @!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)
150
154
  # Recognize audio.
151
- # Sends audio and returns transcription results for a recognition request. Returns
152
- # only the final results; to enable interim results, use the WebSocket API. The
153
- # service imposes a data size limit of 100 MB. It automatically detects the
154
- # endianness of the incoming audio and, for audio that includes multiple channels,
155
- # downmixes the audio to one-channel mono during transcoding.
155
+ # Sends audio and returns transcription results for a recognition request. You can
156
+ # pass a maximum of 100 MB and a minimum of 100 bytes of audio with a request. The
157
+ # service automatically detects the endianness of the incoming audio and, for audio
158
+ # that includes multiple channels, downmixes the audio to one-channel mono during
159
+ # transcoding. The method returns only final results; to enable interim results, use
160
+ # the WebSocket API.
156
161
  #
157
162
  # **See also:** [Making a basic HTTP
158
163
  # request](https://console.bluemix.net/docs/services/speech-to-text/http.html#HTTP-basic).
159
164
  #
160
- #
161
165
  # ### Streaming mode
162
166
  #
163
167
  # For requests to transcribe live audio as it becomes available, you must set the
@@ -169,11 +173,8 @@ module IBMWatson
169
173
  # `inactivity_timeout` parameter to change the default of 30 seconds.
170
174
  #
171
175
  # **See also:**
172
- # * [Audio
173
- # transmission](https://console.bluemix.net/docs/services/speech-to-text/input.html#transmission)
174
- # *
175
- # [Timeouts](https://console.bluemix.net/docs/services/speech-to-text/input.html#timeouts).
176
- #
176
+ # * [Audio transmission](https://console.bluemix.net/docs/services/speech-to-text/input.html#transmission)
177
+ # * [Timeouts](https://console.bluemix.net/docs/services/speech-to-text/input.html#timeouts)
177
178
  #
178
179
  # ### Audio formats (content types)
179
180
  #
@@ -202,19 +203,16 @@ module IBMWatson
202
203
  # * `audio/webm;codecs=opus`
203
204
  # * `audio/webm;codecs=vorbis`
204
205
  #
205
- # **See also:** [Audio
206
- # formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html).
207
- #
208
- #
209
- # **Note:** You must pass a content type when using any of the Watson SDKs. The SDKs
210
- # require the content-type parameter for all audio formats.
206
+ # **See also:** [Audio formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html).
211
207
  #
212
208
  # ### Multipart speech recognition
213
209
  #
214
- # The method also supports multipart recognition requests. With multipart requests,
215
- # you pass all audio data as multipart form data. You specify some parameters as
216
- # request headers and query parameters, but you pass JSON metadata as form data to
217
- # control most aspects of the transcription.
210
+ # **Note:** The Watson SDKs do not support multipart speech recognition.
211
+ #
212
+ # The HTTP `POST` method of the service also supports multipart speech recognition.
213
+ # With multipart requests, you pass all audio data as multipart form data. You
214
+ # specify some parameters as request headers and query parameters, but you pass JSON
215
+ # metadata as form data to control most aspects of the transcription.
218
216
  #
219
217
  # The multipart approach is intended for use with browsers for which JavaScript is
220
218
  # disabled or when the parameters used with the request are greater than the 8 KB
@@ -224,7 +222,8 @@ module IBMWatson
224
222
  # **See also:** [Making a multipart HTTP
225
223
  # request](https://console.bluemix.net/docs/services/speech-to-text/http.html#HTTP-multi).
226
224
  # @param audio [String] The audio to transcribe.
227
- # @param content_type [String] The type of the input.
225
+ # @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
226
+ # audio format, see **Audio formats (content types)** in the method description.
228
227
  # @param model [String] The identifier of the model that is to be used for the recognition request.
229
228
  # @param language_customization_id [String] The customization ID (GUID) of a custom language model that is to be used with the
230
229
  # recognition request. The base model of the specified custom language model must
@@ -233,7 +232,6 @@ module IBMWatson
233
232
  # custom model. By default, no custom language model is used. See [Custom
234
233
  # models](https://console.bluemix.net/docs/services/speech-to-text/input.html#custom).
235
234
  #
236
- #
237
235
  # **Note:** Use this parameter instead of the deprecated `customization_id`
238
236
  # parameter.
239
237
  # @param acoustic_customization_id [String] The customization ID (GUID) of a custom acoustic model that is to be used with the
@@ -264,8 +262,7 @@ module IBMWatson
264
262
  # custom model's domain, but it can negatively affect performance on non-domain
265
263
  # phrases.
266
264
  #
267
- # See [Custom
268
- # models](https://console.bluemix.net/docs/services/speech-to-text/input.html#custom).
265
+ # See [Custom models](https://console.bluemix.net/docs/services/speech-to-text/input.html#custom).
269
266
  # @param inactivity_timeout [Fixnum] The time in seconds after which, if only silence (no speech) is detected in
270
267
  # submitted audio, the connection is closed with a 400 error. The parameter is
271
268
  # useful for stopping audio submission from a live microphone when a user simply
@@ -307,23 +304,23 @@ module IBMWatson
307
304
  # numbers, currency values, and internet addresses into more readable, conventional
308
305
  # representations in the final transcript of a recognition request. For US English,
309
306
  # the service also converts certain keyword strings to punctuation symbols. By
310
- # default, no smart formatting is performed. Applies to US English and Spanish
311
- # transcription only. See [Smart
307
+ # default, no smart formatting is performed. Applies to US English, Japanese, and
308
+ # Spanish transcription only. See [Smart
312
309
  # formatting](https://console.bluemix.net/docs/services/speech-to-text/output.html#smart_formatting).
313
310
  # @param speaker_labels [Boolean] If `true`, the response includes labels that identify which words were spoken by
314
311
  # which participants in a multi-person exchange. By default, no speaker labels are
315
312
  # returned. Setting `speaker_labels` to `true` forces the `timestamps` parameter to
316
- # be `true`, regardless of whether you specify `false` for the parameter. To
317
- # determine whether a language model supports speaker labels, use the **Get models**
318
- # method and check that the attribute `speaker_labels` is set to `true`. See
319
- # [Speaker
320
- # labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels).
313
+ # be `true`, regardless of whether you specify `false` for the parameter.
314
+ #
315
+ # To determine whether a language model supports speaker labels, use the **Get a
316
+ # model** method and check that the attribute `speaker_labels` is set to `true`. See
317
+ # [Speaker labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels).
321
318
  # @param customization_id [String] **Deprecated.** Use the `language_customization_id` parameter to specify the
322
319
  # customization ID (GUID) of a custom language model that is to be used with the
323
320
  # recognition request. Do not specify both parameters with a request.
324
321
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
325
322
  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)
326
- raise ArgumentError("audio must be provided") if audio.nil?
323
+ raise ArgumentError.new("audio must be provided") if audio.nil?
327
324
 
328
325
  headers = {
329
326
  "Content-Type" => content_type
@@ -347,8 +344,11 @@ module IBMWatson
347
344
  "speaker_labels" => speaker_labels,
348
345
  "customization_id" => customization_id
349
346
  }
347
+
350
348
  data = audio
349
+
351
350
  method_url = "/v1/recognize"
351
+
352
352
  response = request(
353
353
  method: "POST",
354
354
  url: method_url,
@@ -361,7 +361,7 @@ module IBMWatson
361
361
  end
362
362
 
363
363
  ##
364
- # @!method recognize_using_websocket(content_type: nil,recognize_callback:,audio: nil,chunk_data: false,model: nil,customization_id: nil,language_customization_id: nil,acoustic_customization_id: nil,customization_weight: nil,base_model_version: nil,inactivity_timeout: nil,interim_results: 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)
364
+ # @!method recognize_using_websocket(content_type: nil,recognize_callback:,audio: nil,chunk_data: false,model: nil,customization_id: nil,acoustic_customization_id: nil,customization_weight: nil,base_model_version: nil,inactivity_timeout: nil,interim_results: 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)
365
365
  # Sends audio for speech recognition using web sockets.
366
366
  # @param content_type [String] The type of the input: audio/basic, audio/flac, audio/l16, audio/mp3, audio/mpeg, audio/mulaw, audio/ogg, audio/ogg;codecs=opus, audio/ogg;codecs=vorbis, audio/wav, audio/webm, audio/webm;codecs=opus, audio/webm;codecs=vorbis, or multipart/form-data.
367
367
  # @param recognize_callback [RecognizeCallback] The instance handling events returned from the service.
@@ -369,7 +369,7 @@ module IBMWatson
369
369
  # @param chunk_data [Boolean] If true, then the WebSocketClient will expect to receive data in chunks rather than as a single audio file
370
370
  # @param model [String] The identifier of the model to be used for the recognition request.
371
371
  # @param language_customization_id [String] The GUID of a custom language model that is to be used with the request. The base model of the specified custom language model must match the model specified with the `model` parameter. You must make the request with service credentials created for the instance of the service that owns the custom model. By default, no custom language model is used.
372
- # @param customization_id [String] **Deprecated.** Use the `language_customization_id` parameter to specify the customization ID (GUID) of a custom language model that is to be used with the recognition request. Do not specify both parameters with a request.
372
+ # @param customization_id [String] The GUID of a custom language model that is to be used with the request. The base model of the specified custom language model must match the model specified with the `model` parameter. You must make the request with service credentials created for the instance of the service that owns the custom model. By default, no custom language model is used.
373
373
  # @param acoustic_customization_id [String] The GUID of a custom acoustic model that is to be used with the request. The base model of the specified custom acoustic model must match the model specified with the `model` parameter. You must make the request with service credentials created for the instance of the service that owns the custom model. By default, no custom acoustic model is used.
374
374
  # @param customization_weight [Float] If you specify a `customization_id` with the request, you can use the `customization_weight` parameter to tell the service how much weight to give to words from the custom language model compared to those from the base model for speech recognition. Specify a value between 0.0 and 1.0. Unless a different customization weight was specified for the custom model when it was trained, the default value is 0.3. A customization weight that you specify overrides a weight that was specified when the custom model was trained. The default value yields the best performance in general. Assign a higher value if your audio makes frequent use of OOV words from the custom model. Use caution when setting the weight: a higher value can improve the accuracy of phrases from the custom model's domain, but it can negatively affect performance on non-domain phrases.
375
375
  # @param base_model_version [String] The version of the specified base `model` that is to be used for speech recognition. Multiple versions of a base model can exist when a model is updated for internal improvements. The parameter is intended primarily for use with custom models that have been upgraded for a new base model. The default value depends on whether the parameter is used with or without a custom model. For more information, see [Base model version](https://console.bluemix.net/docs/services/speech-to-text/input.html#version).
@@ -552,15 +552,18 @@ module IBMWatson
552
552
  # the parameter, the service does not send the header.
553
553
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
554
554
  def register_callback(callback_url:, user_secret: nil)
555
- raise ArgumentError("callback_url must be provided") if callback_url.nil?
555
+ raise ArgumentError.new("callback_url must be provided") if callback_url.nil?
556
556
 
557
557
  headers = {
558
558
  }
559
+
559
560
  params = {
560
561
  "callback_url" => callback_url,
561
562
  "user_secret" => user_secret
562
563
  }
564
+
563
565
  method_url = "/v1/register_callback"
566
+
564
567
  response = request(
565
568
  method: "POST",
566
569
  url: method_url,
@@ -583,14 +586,17 @@ module IBMWatson
583
586
  # @param callback_url [String] The callback URL that is to be unregistered.
584
587
  # @return [nil]
585
588
  def unregister_callback(callback_url:)
586
- raise ArgumentError("callback_url must be provided") if callback_url.nil?
589
+ raise ArgumentError.new("callback_url must be provided") if callback_url.nil?
587
590
 
588
591
  headers = {
589
592
  }
593
+
590
594
  params = {
591
595
  "callback_url" => callback_url
592
596
  }
597
+
593
598
  method_url = "/v1/unregister_callback"
599
+
594
600
  request(
595
601
  method: "POST",
596
602
  url: method_url,
@@ -634,12 +640,13 @@ module IBMWatson
634
640
  # * `user_token`
635
641
  # * `results_ttl`
636
642
  #
637
- # The service imposes a data size limit of 100 MB. It automatically detects the
638
- # endianness of the incoming audio and, for audio that includes multiple channels,
639
- # downmixes the audio to one-channel mono during transcoding.
643
+ # You can pass a maximum of 100 MB and a minimum of 100 bytes of audio with a
644
+ # request. The service automatically detects the endianness of the incoming audio
645
+ # and, for audio that includes multiple channels, downmixes the audio to one-channel
646
+ # mono during transcoding. The method returns only final results; to enable interim
647
+ # results, use the WebSocket API.
640
648
  #
641
- # **See also:** [Creating a
642
- # job](https://console.bluemix.net/docs/services/speech-to-text/async.html#create).
649
+ # **See also:** [Creating a job](https://console.bluemix.net/docs/services/speech-to-text/async.html#create).
643
650
  #
644
651
  # ### Streaming mode
645
652
  #
@@ -652,11 +659,8 @@ module IBMWatson
652
659
  # `inactivity_timeout` parameter to change the default of 30 seconds.
653
660
  #
654
661
  # **See also:**
655
- # * [Audio
656
- # transmission](https://console.bluemix.net/docs/services/speech-to-text/input.html#transmission)
657
- # *
658
- # [Timeouts](https://console.bluemix.net/docs/services/speech-to-text/input.html#timeouts)
659
- #
662
+ # * [Audio transmission](https://console.bluemix.net/docs/services/speech-to-text/input.html#transmission)
663
+ # * [Timeouts](https://console.bluemix.net/docs/services/speech-to-text/input.html#timeouts)
660
664
  #
661
665
  # ### Audio formats (content types)
662
666
  #
@@ -685,14 +689,10 @@ module IBMWatson
685
689
  # * `audio/webm;codecs=opus`
686
690
  # * `audio/webm;codecs=vorbis`
687
691
  #
688
- # **See also:** [Audio
689
- # formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html).
690
- #
691
- #
692
- # **Note:** You must pass a content type when using any of the Watson SDKs. The SDKs
693
- # require the content-type parameter for all audio formats.
692
+ # **See also:** [Audio formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html).
694
693
  # @param audio [String] The audio to transcribe.
695
- # @param content_type [String] The type of the input.
694
+ # @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
695
+ # audio format, see **Audio formats (content types)** in the method description.
696
696
  # @param model [String] The identifier of the model that is to be used for the recognition request.
697
697
  # @param callback_url [String] A URL to which callback notifications are to be sent. The URL must already be
698
698
  # successfully white-listed by using the **Register a callback** method. You can
@@ -735,7 +735,6 @@ module IBMWatson
735
735
  # custom model. By default, no custom language model is used. See [Custom
736
736
  # models](https://console.bluemix.net/docs/services/speech-to-text/input.html#custom).
737
737
  #
738
- #
739
738
  # **Note:** Use this parameter instead of the deprecated `customization_id`
740
739
  # parameter.
741
740
  # @param acoustic_customization_id [String] The customization ID (GUID) of a custom acoustic model that is to be used with the
@@ -766,8 +765,7 @@ module IBMWatson
766
765
  # custom model's domain, but it can negatively affect performance on non-domain
767
766
  # phrases.
768
767
  #
769
- # See [Custom
770
- # models](https://console.bluemix.net/docs/services/speech-to-text/input.html#custom).
768
+ # See [Custom models](https://console.bluemix.net/docs/services/speech-to-text/input.html#custom).
771
769
  # @param inactivity_timeout [Fixnum] The time in seconds after which, if only silence (no speech) is detected in
772
770
  # submitted audio, the connection is closed with a 400 error. The parameter is
773
771
  # useful for stopping audio submission from a live microphone when a user simply
@@ -809,27 +807,28 @@ module IBMWatson
809
807
  # numbers, currency values, and internet addresses into more readable, conventional
810
808
  # representations in the final transcript of a recognition request. For US English,
811
809
  # the service also converts certain keyword strings to punctuation symbols. By
812
- # default, no smart formatting is performed. Applies to US English and Spanish
813
- # transcription only. See [Smart
810
+ # default, no smart formatting is performed. Applies to US English, Japanese, and
811
+ # Spanish transcription only. See [Smart
814
812
  # formatting](https://console.bluemix.net/docs/services/speech-to-text/output.html#smart_formatting).
815
813
  # @param speaker_labels [Boolean] If `true`, the response includes labels that identify which words were spoken by
816
814
  # which participants in a multi-person exchange. By default, no speaker labels are
817
815
  # returned. Setting `speaker_labels` to `true` forces the `timestamps` parameter to
818
- # be `true`, regardless of whether you specify `false` for the parameter. To
819
- # determine whether a language model supports speaker labels, use the **Get models**
820
- # method and check that the attribute `speaker_labels` is set to `true`. See
821
- # [Speaker
822
- # labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels).
816
+ # be `true`, regardless of whether you specify `false` for the parameter.
817
+ #
818
+ # To determine whether a language model supports speaker labels, use the **Get a
819
+ # model** method and check that the attribute `speaker_labels` is set to `true`. See
820
+ # [Speaker labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels).
823
821
  # @param customization_id [String] **Deprecated.** Use the `language_customization_id` parameter to specify the
824
822
  # customization ID (GUID) of a custom language model that is to be used with the
825
823
  # recognition request. Do not specify both parameters with a request.
826
824
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
827
825
  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)
828
- raise ArgumentError("audio must be provided") if audio.nil?
826
+ raise ArgumentError.new("audio must be provided") if audio.nil?
829
827
 
830
828
  headers = {
831
829
  "Content-Type" => content_type
832
830
  }
831
+
833
832
  params = {
834
833
  "model" => model,
835
834
  "callback_url" => callback_url,
@@ -852,8 +851,11 @@ module IBMWatson
852
851
  "speaker_labels" => speaker_labels,
853
852
  "customization_id" => customization_id
854
853
  }
854
+
855
855
  data = audio
856
+
856
857
  method_url = "/v1/recognitions"
858
+
857
859
  response = request(
858
860
  method: "POST",
859
861
  url: method_url,
@@ -883,7 +885,9 @@ module IBMWatson
883
885
  def check_jobs
884
886
  headers = {
885
887
  }
888
+
886
889
  method_url = "/v1/recognitions"
890
+
887
891
  response = request(
888
892
  method: "GET",
889
893
  url: method_url,
@@ -912,11 +916,13 @@ module IBMWatson
912
916
  # @param id [String] The identifier of the asynchronous job that is to be used for the request.
913
917
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
914
918
  def check_job(id:)
915
- raise ArgumentError("id must be provided") if id.nil?
919
+ raise ArgumentError.new("id must be provided") if id.nil?
916
920
 
917
921
  headers = {
918
922
  }
923
+
919
924
  method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
925
+
920
926
  response = request(
921
927
  method: "GET",
922
928
  url: method_url,
@@ -935,16 +941,17 @@ module IBMWatson
935
941
  # results expires. You must submit the request with the service credentials of the
936
942
  # user who created the job.
937
943
  #
938
- # **See also:** [Deleting a
939
- # job](https://console.bluemix.net/docs/services/speech-to-text/async.html#delete).
944
+ # **See also:** [Deleting a job](https://console.bluemix.net/docs/services/speech-to-text/async.html#delete).
940
945
  # @param id [String] The identifier of the asynchronous job that is to be used for the request.
941
946
  # @return [nil]
942
947
  def delete_job(id:)
943
- raise ArgumentError("id must be provided") if id.nil?
948
+ raise ArgumentError.new("id must be provided") if id.nil?
944
949
 
945
950
  headers = {
946
951
  }
952
+
947
953
  method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
954
+
948
955
  request(
949
956
  method: "DELETE",
950
957
  url: method_url,
@@ -973,10 +980,11 @@ module IBMWatson
973
980
  # custom model, such as `Medical custom model` or `Legal custom model`.
974
981
  # @param base_model_name [String] The name of the base language model that is to be customized by the new custom
975
982
  # language model. The new custom model can be used only with the base model that it
976
- # customizes. To determine whether a base model supports language model
977
- # customization, request information about the base model and check that the
978
- # attribute `custom_language_model` is set to `true`, or refer to [Language support
979
- # for
983
+ # customizes.
984
+ #
985
+ # To determine whether a base model supports language model customization, use the
986
+ # **Get a model** method and check that the attribute `custom_language_model` is set
987
+ # to `true`. You can also refer to [Language support for
980
988
  # customization](https://console.bluemix.net/docs/services/speech-to-text/custom.html#languageSupport).
981
989
  # @param dialect [String] The dialect of the specified language that is to be used with the custom language
982
990
  # model. The parameter is meaningful only for Spanish models, for which the service
@@ -993,19 +1001,22 @@ module IBMWatson
993
1001
  # matches the language of the custom model.
994
1002
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
995
1003
  def create_language_model(name:, base_model_name:, dialect: nil, description: nil)
996
- raise ArgumentError("name must be provided") if name.nil?
1004
+ raise ArgumentError.new("name must be provided") if name.nil?
997
1005
 
998
- raise ArgumentError("base_model_name must be provided") if base_model_name.nil?
1006
+ raise ArgumentError.new("base_model_name must be provided") if base_model_name.nil?
999
1007
 
1000
1008
  headers = {
1001
1009
  }
1010
+
1002
1011
  data = {
1003
1012
  "name" => name,
1004
1013
  "base_model_name" => base_model_name,
1005
1014
  "dialect" => dialect,
1006
1015
  "description" => description
1007
1016
  }
1017
+
1008
1018
  method_url = "/v1/customizations"
1019
+
1009
1020
  response = request(
1010
1021
  method: "POST",
1011
1022
  url: method_url,
@@ -1034,10 +1045,13 @@ module IBMWatson
1034
1045
  def list_language_models(language: nil)
1035
1046
  headers = {
1036
1047
  }
1048
+
1037
1049
  params = {
1038
1050
  "language" => language
1039
1051
  }
1052
+
1040
1053
  method_url = "/v1/customizations"
1054
+
1041
1055
  response = request(
1042
1056
  method: "GET",
1043
1057
  url: method_url,
@@ -1061,11 +1075,13 @@ module IBMWatson
1061
1075
  # instance of the service that owns the custom model.
1062
1076
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1063
1077
  def get_language_model(customization_id:)
1064
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1078
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1065
1079
 
1066
1080
  headers = {
1067
1081
  }
1082
+
1068
1083
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
1084
+
1069
1085
  response = request(
1070
1086
  method: "GET",
1071
1087
  url: method_url,
@@ -1090,11 +1106,13 @@ module IBMWatson
1090
1106
  # instance of the service that owns the custom model.
1091
1107
  # @return [nil]
1092
1108
  def delete_language_model(customization_id:)
1093
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1109
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1094
1110
 
1095
1111
  headers = {
1096
1112
  }
1113
+
1097
1114
  method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
1115
+
1098
1116
  request(
1099
1117
  method: "DELETE",
1100
1118
  url: method_url,
@@ -1161,15 +1179,18 @@ module IBMWatson
1161
1179
  # weight for that request.
1162
1180
  # @return [nil]
1163
1181
  def train_language_model(customization_id:, word_type_to_add: nil, customization_weight: nil)
1164
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1182
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1165
1183
 
1166
1184
  headers = {
1167
1185
  }
1186
+
1168
1187
  params = {
1169
1188
  "word_type_to_add" => word_type_to_add,
1170
1189
  "customization_weight" => customization_weight
1171
1190
  }
1191
+
1172
1192
  method_url = "/v1/customizations/%s/train" % [ERB::Util.url_encode(customization_id)]
1193
+
1173
1194
  request(
1174
1195
  method: "POST",
1175
1196
  url: method_url,
@@ -1196,11 +1217,13 @@ module IBMWatson
1196
1217
  # instance of the service that owns the custom model.
1197
1218
  # @return [nil]
1198
1219
  def reset_language_model(customization_id:)
1199
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1220
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1200
1221
 
1201
1222
  headers = {
1202
1223
  }
1224
+
1203
1225
  method_url = "/v1/customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
1226
+
1204
1227
  request(
1205
1228
  method: "POST",
1206
1229
  url: method_url,
@@ -1236,11 +1259,13 @@ module IBMWatson
1236
1259
  # instance of the service that owns the custom model.
1237
1260
  # @return [nil]
1238
1261
  def upgrade_language_model(customization_id:)
1239
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1262
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1240
1263
 
1241
1264
  headers = {
1242
1265
  }
1266
+
1243
1267
  method_url = "/v1/customizations/%s/upgrade_model" % [ERB::Util.url_encode(customization_id)]
1268
+
1244
1269
  request(
1245
1270
  method: "POST",
1246
1271
  url: method_url,
@@ -1268,11 +1293,13 @@ module IBMWatson
1268
1293
  # instance of the service that owns the custom model.
1269
1294
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1270
1295
  def list_corpora(customization_id:)
1271
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1296
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1272
1297
 
1273
1298
  headers = {
1274
1299
  }
1300
+
1275
1301
  method_url = "/v1/customizations/%s/corpora" % [ERB::Util.url_encode(customization_id)]
1302
+
1276
1303
  response = request(
1277
1304
  method: "GET",
1278
1305
  url: method_url,
@@ -1342,44 +1369,50 @@ module IBMWatson
1342
1369
  # words that are added or modified by the user.
1343
1370
  # @param corpus_file [File] A plain text file that contains the training data for the corpus. Encode the file
1344
1371
  # in UTF-8 if it contains non-ASCII characters; the service assumes UTF-8 encoding
1345
- # if it encounters non-ASCII characters. With the `curl` command, use the
1346
- # `--data-binary` option to upload the file for the request.
1347
- # @param allow_overwrite [Boolean] If `true`, the specified corpus or audio resource overwrites an existing corpus or
1348
- # audio resource with the same name. If `false`, the request fails if a corpus or
1349
- # audio resource with the same name already exists. The parameter has no effect if a
1350
- # corpus or audio resource with the same name does not already exist.
1372
+ # if it encounters non-ASCII characters.
1373
+ #
1374
+ # Make sure that you know the character encoding of the file. You must use that
1375
+ # encoding when working with the words in the custom language model. For more
1376
+ # information, see [Character
1377
+ # encoding](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#charEncoding).
1378
+ #
1379
+ # With the `curl` command, use the `--data-binary` option to upload the file for the
1380
+ # request.
1381
+ # @param allow_overwrite [Boolean] If `true`, the specified corpus overwrites an existing corpus with the same name.
1382
+ # If `false`, the request fails if a corpus with the same name already exists. The
1383
+ # parameter has no effect if a corpus with the same name does not already exist.
1351
1384
  # @param corpus_filename [String] The filename for corpus_file.
1352
1385
  # @return [nil]
1353
1386
  def add_corpus(customization_id:, corpus_name:, corpus_file:, allow_overwrite: nil, corpus_filename: nil)
1354
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1387
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1355
1388
 
1356
- raise ArgumentError("corpus_name must be provided") if corpus_name.nil?
1389
+ raise ArgumentError.new("corpus_name must be provided") if corpus_name.nil?
1357
1390
 
1358
- raise ArgumentError("corpus_file must be provided") if corpus_file.nil?
1391
+ raise ArgumentError.new("corpus_file must be provided") if corpus_file.nil?
1359
1392
 
1360
1393
  headers = {
1361
1394
  }
1395
+
1362
1396
  params = {
1363
1397
  "allow_overwrite" => allow_overwrite
1364
1398
  }
1365
- mime_type = "text/plain"
1399
+
1400
+ form_data = {}
1401
+
1366
1402
  unless corpus_file.instance_of?(StringIO) || corpus_file.instance_of?(File)
1367
1403
  corpus_file = corpus_file.respond_to?(:to_json) ? StringIO.new(corpus_file.to_json) : StringIO.new(corpus_file)
1368
1404
  end
1369
- if corpus_filename
1370
- corpus_file = corpus_file.instance_of?(StringIO) ? HTTP::FormData::File.new(corpus_file, content_type: mime_type, filename: corpus_filename) : HTTP::FormData::File.new(corpus_file.path, content_type: mime_type, filename: corpus_filename)
1371
- else
1372
- corpus_file = corpus_file.instance_of?(StringIO) ? HTTP::FormData::File.new(corpus_file, content_type: mime_type) : HTTP::FormData::File.new(corpus_file.path, content_type: mime_type)
1373
- end
1405
+ corpus_filename = corpus_file.path if corpus_filename.nil? && corpus_file.respond_to?(:path)
1406
+ form_data[:corpus_file] = HTTP::FormData::File.new(corpus_file, content_type: "text/plain", filename: corpus_filename)
1407
+
1374
1408
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1409
+
1375
1410
  request(
1376
1411
  method: "POST",
1377
1412
  url: method_url,
1378
1413
  headers: headers,
1379
1414
  params: params,
1380
- form: {
1381
- corpus_file: corpus_file
1382
- },
1415
+ form: form_data,
1383
1416
  accept_json: true
1384
1417
  )
1385
1418
  nil
@@ -1401,13 +1434,15 @@ module IBMWatson
1401
1434
  # @param corpus_name [String] The name of the corpus for the custom language model.
1402
1435
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1403
1436
  def get_corpus(customization_id:, corpus_name:)
1404
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1437
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1405
1438
 
1406
- raise ArgumentError("corpus_name must be provided") if corpus_name.nil?
1439
+ raise ArgumentError.new("corpus_name must be provided") if corpus_name.nil?
1407
1440
 
1408
1441
  headers = {
1409
1442
  }
1443
+
1410
1444
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1445
+
1411
1446
  response = request(
1412
1447
  method: "GET",
1413
1448
  url: method_url,
@@ -1436,13 +1471,15 @@ module IBMWatson
1436
1471
  # @param corpus_name [String] The name of the corpus for the custom language model.
1437
1472
  # @return [nil]
1438
1473
  def delete_corpus(customization_id:, corpus_name:)
1439
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1474
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1440
1475
 
1441
- raise ArgumentError("corpus_name must be provided") if corpus_name.nil?
1476
+ raise ArgumentError.new("corpus_name must be provided") if corpus_name.nil?
1442
1477
 
1443
1478
  headers = {
1444
1479
  }
1480
+
1445
1481
  method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
1482
+
1446
1483
  request(
1447
1484
  method: "DELETE",
1448
1485
  url: method_url,
@@ -1484,15 +1521,18 @@ module IBMWatson
1484
1521
  # alphabetically. With the `curl` command, URL encode the `+` symbol as `%2B`.
1485
1522
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1486
1523
  def list_words(customization_id:, word_type: nil, sort: nil)
1487
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1524
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1488
1525
 
1489
1526
  headers = {
1490
1527
  }
1528
+
1491
1529
  params = {
1492
1530
  "word_type" => word_type,
1493
1531
  "sort" => sort
1494
1532
  }
1533
+
1495
1534
  method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
1535
+
1496
1536
  response = request(
1497
1537
  method: "GET",
1498
1538
  url: method_url,
@@ -1570,16 +1610,19 @@ module IBMWatson
1570
1610
  # added to or updated in the custom language model.
1571
1611
  # @return [nil]
1572
1612
  def add_words(customization_id:, words:)
1573
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1613
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1574
1614
 
1575
- raise ArgumentError("words must be provided") if words.nil?
1615
+ raise ArgumentError.new("words must be provided") if words.nil?
1576
1616
 
1577
1617
  headers = {
1578
1618
  }
1619
+
1579
1620
  data = {
1580
1621
  "words" => words
1581
1622
  }
1623
+
1582
1624
  method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
1625
+
1583
1626
  request(
1584
1627
  method: "POST",
1585
1628
  url: method_url,
@@ -1634,14 +1677,16 @@ module IBMWatson
1634
1677
  # @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
1635
1678
  # the request. You must make the request with service credentials created for the
1636
1679
  # instance of the service that owns the custom model.
1637
- # @param word_name [String] The custom word for the custom language model. When you add or update a custom
1638
- # word with the **Add a custom word** method, do not include spaces in the word. Use
1639
- # a `-` (dash) or `_` (underscore) to connect the tokens of compound words.
1680
+ # @param word_name [String] The custom word that is to be added to or updated in the custom language model. Do
1681
+ # not include spaces in the word. Use a `-` (dash) or `_` (underscore) to connect
1682
+ # the tokens of compound words. URL-encode the word if it includes non-ASCII
1683
+ # characters. For more information, see [Character
1684
+ # encoding](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#charEncoding).
1640
1685
  # @param word [String] For the **Add custom words** method, you must specify the custom word that is to
1641
1686
  # be added to or updated in the custom model. Do not include spaces in the word. Use
1642
1687
  # a `-` (dash) or `_` (underscore) to connect the tokens of compound words.
1643
1688
  #
1644
- # Omit this field for the **Add a custom word** method.
1689
+ # Omit this parameter for the **Add a custom word** method.
1645
1690
  # @param sounds_like [Array[String]] An array of sounds-like pronunciations for the custom word. Specify how words that
1646
1691
  # are difficult to pronounce, foreign words, acronyms, and so on can be pronounced
1647
1692
  # by users.
@@ -1659,18 +1704,21 @@ module IBMWatson
1659
1704
  # usual representation or from its spelling in corpora training data.
1660
1705
  # @return [nil]
1661
1706
  def add_word(customization_id:, word_name:, word: nil, sounds_like: nil, display_as: nil)
1662
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1707
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1663
1708
 
1664
- raise ArgumentError("word_name must be provided") if word_name.nil?
1709
+ raise ArgumentError.new("word_name must be provided") if word_name.nil?
1665
1710
 
1666
1711
  headers = {
1667
1712
  }
1713
+
1668
1714
  data = {
1669
1715
  "word" => word,
1670
1716
  "sounds_like" => sounds_like,
1671
1717
  "display_as" => display_as
1672
1718
  }
1719
+
1673
1720
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
1721
+
1674
1722
  request(
1675
1723
  method: "PUT",
1676
1724
  url: method_url,
@@ -1693,18 +1741,20 @@ module IBMWatson
1693
1741
  # @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
1694
1742
  # the request. You must make the request with service credentials created for the
1695
1743
  # instance of the service that owns the custom model.
1696
- # @param word_name [String] The custom word for the custom language model. When you add or update a custom
1697
- # word with the **Add a custom word** method, do not include spaces in the word. Use
1698
- # a `-` (dash) or `_` (underscore) to connect the tokens of compound words.
1744
+ # @param word_name [String] The custom word that is to be read from the custom language model. URL-encode the
1745
+ # word if it includes non-ASCII characters. For more information, see [Character
1746
+ # encoding](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#charEncoding).
1699
1747
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1700
1748
  def get_word(customization_id:, word_name:)
1701
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1749
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1702
1750
 
1703
- raise ArgumentError("word_name must be provided") if word_name.nil?
1751
+ raise ArgumentError.new("word_name must be provided") if word_name.nil?
1704
1752
 
1705
1753
  headers = {
1706
1754
  }
1755
+
1707
1756
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
1757
+
1708
1758
  response = request(
1709
1759
  method: "GET",
1710
1760
  url: method_url,
@@ -1730,18 +1780,20 @@ module IBMWatson
1730
1780
  # @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
1731
1781
  # the request. You must make the request with service credentials created for the
1732
1782
  # instance of the service that owns the custom model.
1733
- # @param word_name [String] The custom word for the custom language model. When you add or update a custom
1734
- # word with the **Add a custom word** method, do not include spaces in the word. Use
1735
- # a `-` (dash) or `_` (underscore) to connect the tokens of compound words.
1783
+ # @param word_name [String] The custom word that is to be deleted from the custom language model. URL-encode
1784
+ # the word if it includes non-ASCII characters. For more information, see [Character
1785
+ # encoding](https://console.bluemix.net/docs/services/speech-to-text/language-resource.html#charEncoding).
1736
1786
  # @return [nil]
1737
1787
  def delete_word(customization_id:, word_name:)
1738
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1788
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1739
1789
 
1740
- raise ArgumentError("word_name must be provided") if word_name.nil?
1790
+ raise ArgumentError.new("word_name must be provided") if word_name.nil?
1741
1791
 
1742
1792
  headers = {
1743
1793
  }
1794
+
1744
1795
  method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
1796
+
1745
1797
  request(
1746
1798
  method: "DELETE",
1747
1799
  url: method_url,
@@ -1771,25 +1823,30 @@ module IBMWatson
1771
1823
  # custom model`.
1772
1824
  # @param base_model_name [String] The name of the base language model that is to be customized by the new custom
1773
1825
  # acoustic model. The new custom model can be used only with the base model that it
1774
- # customizes. To determine whether a base model supports acoustic model
1775
- # customization, refer to [Language support for
1826
+ # customizes.
1827
+ #
1828
+ # To determine whether a base model supports acoustic model customization, refer to
1829
+ # [Language support for
1776
1830
  # customization](https://console.bluemix.net/docs/services/speech-to-text/custom.html#languageSupport).
1777
1831
  # @param description [String] A description of the new custom acoustic model. Use a localized description that
1778
1832
  # matches the language of the custom model.
1779
1833
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1780
1834
  def create_acoustic_model(name:, base_model_name:, description: nil)
1781
- raise ArgumentError("name must be provided") if name.nil?
1835
+ raise ArgumentError.new("name must be provided") if name.nil?
1782
1836
 
1783
- raise ArgumentError("base_model_name must be provided") if base_model_name.nil?
1837
+ raise ArgumentError.new("base_model_name must be provided") if base_model_name.nil?
1784
1838
 
1785
1839
  headers = {
1786
1840
  }
1841
+
1787
1842
  data = {
1788
1843
  "name" => name,
1789
1844
  "base_model_name" => base_model_name,
1790
1845
  "description" => description
1791
1846
  }
1847
+
1792
1848
  method_url = "/v1/acoustic_customizations"
1849
+
1793
1850
  response = request(
1794
1851
  method: "POST",
1795
1852
  url: method_url,
@@ -1818,10 +1875,13 @@ module IBMWatson
1818
1875
  def list_acoustic_models(language: nil)
1819
1876
  headers = {
1820
1877
  }
1878
+
1821
1879
  params = {
1822
1880
  "language" => language
1823
1881
  }
1882
+
1824
1883
  method_url = "/v1/acoustic_customizations"
1884
+
1825
1885
  response = request(
1826
1886
  method: "GET",
1827
1887
  url: method_url,
@@ -1845,11 +1905,13 @@ module IBMWatson
1845
1905
  # instance of the service that owns the custom model.
1846
1906
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
1847
1907
  def get_acoustic_model(customization_id:)
1848
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1908
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1849
1909
 
1850
1910
  headers = {
1851
1911
  }
1912
+
1852
1913
  method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
1914
+
1853
1915
  response = request(
1854
1916
  method: "GET",
1855
1917
  url: method_url,
@@ -1874,11 +1936,13 @@ module IBMWatson
1874
1936
  # instance of the service that owns the custom model.
1875
1937
  # @return [nil]
1876
1938
  def delete_acoustic_model(customization_id:)
1877
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
1939
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1878
1940
 
1879
1941
  headers = {
1880
1942
  }
1943
+
1881
1944
  method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
1945
+
1882
1946
  request(
1883
1947
  method: "DELETE",
1884
1948
  url: method_url,
@@ -1939,14 +2003,17 @@ module IBMWatson
1939
2003
  # words that are relevant to the contents of the audio resources.
1940
2004
  # @return [nil]
1941
2005
  def train_acoustic_model(customization_id:, custom_language_model_id: nil)
1942
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
2006
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1943
2007
 
1944
2008
  headers = {
1945
2009
  }
2010
+
1946
2011
  params = {
1947
2012
  "custom_language_model_id" => custom_language_model_id
1948
2013
  }
2014
+
1949
2015
  method_url = "/v1/acoustic_customizations/%s/train" % [ERB::Util.url_encode(customization_id)]
2016
+
1950
2017
  request(
1951
2018
  method: "POST",
1952
2019
  url: method_url,
@@ -1973,11 +2040,13 @@ module IBMWatson
1973
2040
  # instance of the service that owns the custom model.
1974
2041
  # @return [nil]
1975
2042
  def reset_acoustic_model(customization_id:)
1976
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
2043
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
1977
2044
 
1978
2045
  headers = {
1979
2046
  }
2047
+
1980
2048
  method_url = "/v1/acoustic_customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
2049
+
1981
2050
  request(
1982
2051
  method: "POST",
1983
2052
  url: method_url,
@@ -2023,14 +2092,17 @@ module IBMWatson
2023
2092
  # must be upgraded before the custom acoustic model can be upgraded.
2024
2093
  # @return [nil]
2025
2094
  def upgrade_acoustic_model(customization_id:, custom_language_model_id: nil)
2026
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
2095
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
2027
2096
 
2028
2097
  headers = {
2029
2098
  }
2099
+
2030
2100
  params = {
2031
2101
  "custom_language_model_id" => custom_language_model_id
2032
2102
  }
2103
+
2033
2104
  method_url = "/v1/acoustic_customizations/%s/upgrade_model" % [ERB::Util.url_encode(customization_id)]
2105
+
2034
2106
  request(
2035
2107
  method: "POST",
2036
2108
  url: method_url,
@@ -2061,11 +2133,13 @@ module IBMWatson
2061
2133
  # instance of the service that owns the custom model.
2062
2134
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2063
2135
  def list_audio(customization_id:)
2064
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
2136
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
2065
2137
 
2066
2138
  headers = {
2067
2139
  }
2140
+
2068
2141
  method_url = "/v1/acoustic_customizations/%s/audio" % [ERB::Util.url_encode(customization_id)]
2142
+
2069
2143
  response = request(
2070
2144
  method: "GET",
2071
2145
  url: method_url,
@@ -2076,7 +2150,7 @@ module IBMWatson
2076
2150
  end
2077
2151
 
2078
2152
  ##
2079
- # @!method add_audio(customization_id:, audio_name:, audio_resource:, content_type:, contained_content_type: nil, allow_overwrite: nil)
2153
+ # @!method add_audio(customization_id:, audio_name:, audio_resource:, content_type: nil, contained_content_type: nil, allow_overwrite: nil)
2080
2154
  # Add an audio resource.
2081
2155
  # Adds an audio resource to a custom acoustic model. Add audio content that reflects
2082
2156
  # the acoustic characteristics of the audio that you plan to transcribe. You must
@@ -2117,7 +2191,6 @@ module IBMWatson
2117
2191
  # **See also:** [Add audio to the custom acoustic
2118
2192
  # model](https://console.bluemix.net/docs/services/speech-to-text/acoustic-create.html#addAudio).
2119
2193
  #
2120
- #
2121
2194
  # ### Content types for audio-type resources
2122
2195
  #
2123
2196
  # You can add an individual audio file in any format that the service supports for
@@ -2139,9 +2212,7 @@ module IBMWatson
2139
2212
  # * `audio/webm;codecs=opus`
2140
2213
  # * `audio/webm;codecs=vorbis`
2141
2214
  #
2142
- # **See also:** [Audio
2143
- # formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html).
2144
- #
2215
+ # **See also:** [Audio formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html).
2145
2216
  #
2146
2217
  # **Note:** The sampling rate of an audio file must match the sampling rate of the
2147
2218
  # base model for the custom model: for broadband models, at least 16 kHz; for
@@ -2187,35 +2258,43 @@ module IBMWatson
2187
2258
  # custom model.
2188
2259
  # @param audio_resource [String] The audio resource that is to be added to the custom acoustic model, an individual
2189
2260
  # audio file or an archive file.
2190
- # @param content_type [String] The type of the input.
2191
- # @param contained_content_type [String] For an archive-type resource, specifies the format of the audio files contained in
2192
- # the archive file. The parameter accepts all of the audio formats supported for use
2193
- # with speech recognition, including the `rate`, `channels`, and `endianness`
2194
- # parameters that are used with some formats. For a complete list of supported audio
2195
- # formats, see [Audio formats](/docs/services/speech-to-text/input.html#formats).
2196
- # @param allow_overwrite [Boolean] If `true`, the specified corpus or audio resource overwrites an existing corpus or
2197
- # audio resource with the same name. If `false`, the request fails if a corpus or
2198
- # audio resource with the same name already exists. The parameter has no effect if a
2199
- # corpus or audio resource with the same name does not already exist.
2261
+ # @param content_type [String] For an audio-type resource, the format (MIME type) of the audio. For more
2262
+ # information, see **Content types for audio-type resources** in the method
2263
+ # description.
2264
+ #
2265
+ # For an archive-type resource, the media type of the archive file. For more
2266
+ # information, see **Content types for archive-type resources** in the method
2267
+ # description.
2268
+ # @param contained_content_type [String] For an archive-type resource, specifies the format of the audio files that are
2269
+ # contained in the archive file. The parameter accepts all of the audio formats that
2270
+ # are supported for use with speech recognition, including the `rate`, `channels`,
2271
+ # and `endianness` parameters that are used with some formats. For more information,
2272
+ # see **Content types for audio-type resources** in the method description.
2273
+ # @param allow_overwrite [Boolean] If `true`, the specified audio resource overwrites an existing audio resource with
2274
+ # the same name. If `false`, the request fails if an audio resource with the same
2275
+ # name already exists. The parameter has no effect if an audio resource with the
2276
+ # same name does not already exist.
2200
2277
  # @return [nil]
2201
- def add_audio(customization_id:, audio_name:, audio_resource:, content_type:, contained_content_type: nil, allow_overwrite: nil)
2202
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
2203
-
2204
- raise ArgumentError("audio_name must be provided") if audio_name.nil?
2278
+ def add_audio(customization_id:, audio_name:, audio_resource:, content_type: nil, contained_content_type: nil, allow_overwrite: nil)
2279
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
2205
2280
 
2206
- raise ArgumentError("audio_resource must be provided") if audio_resource.nil?
2281
+ raise ArgumentError.new("audio_name must be provided") if audio_name.nil?
2207
2282
 
2208
- raise ArgumentError("content_type must be provided") if content_type.nil?
2283
+ raise ArgumentError.new("audio_resource must be provided") if audio_resource.nil?
2209
2284
 
2210
2285
  headers = {
2211
2286
  "Content-Type" => content_type,
2212
2287
  "Contained-Content-Type" => contained_content_type
2213
2288
  }
2289
+
2214
2290
  params = {
2215
2291
  "allow_overwrite" => allow_overwrite
2216
2292
  }
2293
+
2217
2294
  data = audio_resource
2295
+
2218
2296
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2297
+
2219
2298
  request(
2220
2299
  method: "POST",
2221
2300
  url: method_url,
@@ -2259,13 +2338,15 @@ module IBMWatson
2259
2338
  # @param audio_name [String] The name of the audio resource for the custom acoustic model.
2260
2339
  # @return [DetailedResponse] A `DetailedResponse` object representing the response.
2261
2340
  def get_audio(customization_id:, audio_name:)
2262
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
2341
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
2263
2342
 
2264
- raise ArgumentError("audio_name must be provided") if audio_name.nil?
2343
+ raise ArgumentError.new("audio_name must be provided") if audio_name.nil?
2265
2344
 
2266
2345
  headers = {
2267
2346
  }
2347
+
2268
2348
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2349
+
2269
2350
  response = request(
2270
2351
  method: "GET",
2271
2352
  url: method_url,
@@ -2294,13 +2375,15 @@ module IBMWatson
2294
2375
  # @param audio_name [String] The name of the audio resource for the custom acoustic model.
2295
2376
  # @return [nil]
2296
2377
  def delete_audio(customization_id:, audio_name:)
2297
- raise ArgumentError("customization_id must be provided") if customization_id.nil?
2378
+ raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
2298
2379
 
2299
- raise ArgumentError("audio_name must be provided") if audio_name.nil?
2380
+ raise ArgumentError.new("audio_name must be provided") if audio_name.nil?
2300
2381
 
2301
2382
  headers = {
2302
2383
  }
2384
+
2303
2385
  method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
2386
+
2304
2387
  request(
2305
2388
  method: "DELETE",
2306
2389
  url: method_url,
@@ -2330,14 +2413,17 @@ module IBMWatson
2330
2413
  # @param customer_id [String] The customer ID for which all data is to be deleted.
2331
2414
  # @return [nil]
2332
2415
  def delete_user_data(customer_id:)
2333
- raise ArgumentError("customer_id must be provided") if customer_id.nil?
2416
+ raise ArgumentError.new("customer_id must be provided") if customer_id.nil?
2334
2417
 
2335
2418
  headers = {
2336
2419
  }
2420
+
2337
2421
  params = {
2338
2422
  "customer_id" => customer_id
2339
2423
  }
2424
+
2340
2425
  method_url = "/v1/user_data"
2426
+
2341
2427
  request(
2342
2428
  method: "DELETE",
2343
2429
  url: method_url,