ibm_watson 0.14.0 → 0.15.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ibm_watson/assistant_v1.rb +791 -736
- data/lib/ibm_watson/assistant_v2.rb +12 -8
- data/lib/ibm_watson/common.rb +2 -1
- data/lib/ibm_watson/compare_comply_v1.rb +171 -169
- data/lib/ibm_watson/discovery_v1.rb +778 -689
- data/lib/ibm_watson/language_translator_v3.rb +65 -63
- data/lib/ibm_watson/natural_language_classifier_v1.rb +36 -35
- data/lib/ibm_watson/natural_language_understanding_v1.rb +28 -25
- data/lib/ibm_watson/personality_insights_v3.rb +10 -10
- data/lib/ibm_watson/speech_to_text_v1.rb +764 -702
- data/lib/ibm_watson/text_to_speech_v1.rb +215 -200
- data/lib/ibm_watson/tone_analyzer_v3.rb +10 -9
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +94 -95
- data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +1 -1
- data/test/integration/test_assistant_v1.rb +18 -289
- data/test/integration/test_assistant_v2.rb +21 -31
- data/test/integration/test_discovery_v1.rb +21 -18
- data/test/integration/test_language_translator_v3.rb +3 -3
- data/test/integration/test_natural_language_classifier_v1.rb +3 -3
- data/test/integration/test_natural_language_understanding_v1.rb +16 -20
- data/test/integration/test_personality_insights_v3.rb +12 -40
- data/test/integration/test_speech_to_text_v1.rb +3 -3
- data/test/integration/test_text_to_speech_v1.rb +3 -3
- data/test/integration/test_tone_analyzer_v3.rb +14 -31
- data/test/integration/test_visual_recognition_v3.rb +3 -3
- data/test/unit/test_compare_comply_v1.rb +3 -7
- data/test/unit/test_discovery_v1.rb +21 -7
- data/test/unit/test_language_translator_v3.rb +1 -3
- data/test/unit/test_natural_language_classifier_v1.rb +1 -3
- data/test/unit/test_speech_to_text_v1.rb +25 -7
- data/test/unit/test_text_to_speech_v1.rb +0 -4
- data/test/unit/test_visual_recognition_v3.rb +2 -6
- metadata +2 -2
@@ -41,7 +41,6 @@
|
|
41
41
|
require "concurrent"
|
42
42
|
require "erb"
|
43
43
|
require "json"
|
44
|
-
|
45
44
|
require "ibm_cloud_sdk_core"
|
46
45
|
require_relative "./common.rb"
|
47
46
|
|
@@ -98,21 +97,26 @@ module IBMWatson
|
|
98
97
|
#########################
|
99
98
|
|
100
99
|
##
|
101
|
-
# @!method
|
102
|
-
#
|
103
|
-
#
|
104
|
-
# information includes the name of the model and its minimum
|
105
|
-
# among other things.
|
100
|
+
# @!method get_model(model_id:)
|
101
|
+
# Get a model.
|
102
|
+
# Gets information for a single specified language model that is available for use
|
103
|
+
# with the service. The information includes the name of the model and its minimum
|
104
|
+
# sampling rate in Hertz, among other things.
|
106
105
|
#
|
107
106
|
# **See also:** [Languages and
|
108
107
|
# models](https://cloud.ibm.com/docs/services/speech-to-text/models.html).
|
108
|
+
# @param model_id [String] The identifier of the model in the form of its name from the output of the **Get a
|
109
|
+
# model** method.
|
109
110
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
110
|
-
def
|
111
|
+
def get_model(model_id:)
|
112
|
+
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
113
|
+
|
111
114
|
headers = {
|
112
115
|
}
|
113
|
-
|
116
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "get_model")
|
117
|
+
headers.merge!(sdk_headers)
|
114
118
|
|
115
|
-
method_url = "/v1/models"
|
119
|
+
method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
|
116
120
|
|
117
121
|
response = request(
|
118
122
|
method: "GET",
|
@@ -124,25 +128,22 @@ module IBMWatson
|
|
124
128
|
end
|
125
129
|
|
126
130
|
##
|
127
|
-
# @!method
|
128
|
-
#
|
129
|
-
#
|
130
|
-
#
|
131
|
-
#
|
131
|
+
# @!method list_models
|
132
|
+
# List models.
|
133
|
+
# Lists all language models that are available for use with the service. The
|
134
|
+
# information includes the name of the model and its minimum sampling rate in Hertz,
|
135
|
+
# among other things.
|
132
136
|
#
|
133
137
|
# **See also:** [Languages and
|
134
138
|
# models](https://cloud.ibm.com/docs/services/speech-to-text/models.html).
|
135
|
-
# @param model_id [String] The identifier of the model in the form of its name from the output of the **Get a
|
136
|
-
# model** method.
|
137
139
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
138
|
-
def
|
139
|
-
raise ArgumentError.new("model_id must be provided") if model_id.nil?
|
140
|
-
|
140
|
+
def list_models
|
141
141
|
headers = {
|
142
142
|
}
|
143
|
-
|
143
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "list_models")
|
144
|
+
headers.merge!(sdk_headers)
|
144
145
|
|
145
|
-
method_url = "/v1/models
|
146
|
+
method_url = "/v1/models"
|
146
147
|
|
147
148
|
response = request(
|
148
149
|
method: "GET",
|
@@ -157,7 +158,7 @@ module IBMWatson
|
|
157
158
|
#########################
|
158
159
|
|
159
160
|
##
|
160
|
-
# @!method recognize(audio:,
|
161
|
+
# @!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, content_type: nil)
|
161
162
|
# Recognize audio.
|
162
163
|
# Sends audio and returns transcription results for a recognition request. You can
|
163
164
|
# pass a maximum of 100 MB and a minimum of 100 bytes of audio with a request. The
|
@@ -174,11 +175,11 @@ module IBMWatson
|
|
174
175
|
#
|
175
176
|
# For requests to transcribe live audio as it becomes available, you must set the
|
176
177
|
# `Transfer-Encoding` header to `chunked` to use streaming mode. In streaming mode,
|
177
|
-
# the
|
178
|
-
#
|
179
|
-
# also closes the connection (status code 400) if no speech
|
180
|
-
# `inactivity_timeout` seconds of audio
|
181
|
-
#
|
178
|
+
# the service closes the connection (status code 408) if it does not receive at
|
179
|
+
# least 15 seconds of audio (including silence) in any 30-second period. The service
|
180
|
+
# also closes the connection (status code 400) if it detects no speech for
|
181
|
+
# `inactivity_timeout` seconds of streaming audio; use the `inactivity_timeout`
|
182
|
+
# parameter to change the default of 30 seconds.
|
182
183
|
#
|
183
184
|
# **See also:**
|
184
185
|
# * [Audio
|
@@ -199,6 +200,7 @@ module IBMWatson
|
|
199
200
|
#
|
200
201
|
# Where indicated, the format that you specify must include the sampling rate and
|
201
202
|
# can optionally include the number of channels and the endianness of the audio.
|
203
|
+
# * `audio/alaw` (**Required.** Specify the sampling rate (`rate`) of the audio.)
|
202
204
|
# * `audio/basic` (**Required.** Use only with narrowband models.)
|
203
205
|
# * `audio/flac`
|
204
206
|
# * `audio/g729` (Use only with narrowband models.)
|
@@ -242,8 +244,6 @@ module IBMWatson
|
|
242
244
|
# **See also:** [Making a multipart HTTP
|
243
245
|
# request](https://cloud.ibm.com/docs/services/speech-to-text/http.html#HTTP-multi).
|
244
246
|
# @param audio [String] The audio to transcribe.
|
245
|
-
# @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
|
246
|
-
# audio format, see **Audio formats (content types)** in the method description.
|
247
247
|
# @param model [String] The identifier of the model that is to be used for the recognition request. See
|
248
248
|
# [Languages and
|
249
249
|
# models](https://cloud.ibm.com/docs/services/speech-to-text/models.html).
|
@@ -252,7 +252,8 @@ module IBMWatson
|
|
252
252
|
# match the model specified with the `model` parameter. You must make the request
|
253
253
|
# with credentials for the instance of the service that owns the custom model. By
|
254
254
|
# default, no custom language model is used. See [Custom
|
255
|
-
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom).
|
255
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom-input).
|
256
|
+
#
|
256
257
|
#
|
257
258
|
# **Note:** Use this parameter instead of the deprecated `customization_id`
|
258
259
|
# parameter.
|
@@ -261,7 +262,7 @@ module IBMWatson
|
|
261
262
|
# match the model specified with the `model` parameter. You must make the request
|
262
263
|
# with credentials for the instance of the service that owns the custom model. By
|
263
264
|
# default, no custom acoustic model is used. See [Custom
|
264
|
-
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom).
|
265
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom-input).
|
265
266
|
# @param base_model_version [String] The version of the specified base model that is to be used with recognition
|
266
267
|
# request. Multiple versions of a base model can exist when a model is updated for
|
267
268
|
# internal improvements. The parameter is intended primarily for use with custom
|
@@ -285,12 +286,12 @@ module IBMWatson
|
|
285
286
|
# phrases.
|
286
287
|
#
|
287
288
|
# See [Custom
|
288
|
-
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom).
|
289
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom-input).
|
289
290
|
# @param inactivity_timeout [Fixnum] The time in seconds after which, if only silence (no speech) is detected in
|
290
|
-
#
|
291
|
+
# streaming audio, the connection is closed with a 400 error. The parameter is
|
291
292
|
# useful for stopping audio submission from a live microphone when a user simply
|
292
|
-
# walks away. Use `-1` for infinity. See
|
293
|
-
#
|
293
|
+
# walks away. Use `-1` for infinity. See [Inactivity
|
294
|
+
# timeout](https://cloud.ibm.com/docs/services/speech-to-text/input.html#timeouts-inactivity).
|
294
295
|
# @param keywords [Array[String]] An array of keyword strings to spot in the audio. Each keyword string can include
|
295
296
|
# one or more string tokens. Keywords are spotted only in the final results, not in
|
296
297
|
# interim hypotheses. If you specify any keywords, you must also specify a keywords
|
@@ -304,7 +305,8 @@ module IBMWatson
|
|
304
305
|
# spotting if you omit either parameter. See [Keyword
|
305
306
|
# spotting](https://cloud.ibm.com/docs/services/speech-to-text/output.html#keyword_spotting).
|
306
307
|
# @param max_alternatives [Fixnum] The maximum number of alternative transcripts that the service is to return. By
|
307
|
-
# default, the service returns a single transcript.
|
308
|
+
# default, the service returns a single transcript. If you specify a value of `0`,
|
309
|
+
# the service uses the default value, `1`. See [Maximum
|
308
310
|
# alternatives](https://cloud.ibm.com/docs/services/speech-to-text/output.html#max_alternatives).
|
309
311
|
# @param word_alternatives_threshold [Float] A confidence value that is the lower bound for identifying a hypothesis as a
|
310
312
|
# possible word alternative (also known as \"Confusion Networks\"). An alternative
|
@@ -354,7 +356,7 @@ module IBMWatson
|
|
354
356
|
# specify the name of the custom language model for which the grammar is defined.
|
355
357
|
# The service recognizes only strings that are recognized by the specified grammar;
|
356
358
|
# it does not recognize other custom words from the model's words resource. See
|
357
|
-
# [Grammars](https://cloud.ibm.com/docs/services/speech-to-text/
|
359
|
+
# [Grammars](https://cloud.ibm.com/docs/services/speech-to-text/input.html#grammars-input).
|
358
360
|
# @param redaction [Boolean] If `true`, the service redacts, or masks, numeric data from final transcripts. The
|
359
361
|
# feature redacts any number that has three or more consecutive digits by replacing
|
360
362
|
# each digit with an `X` character. It is intended to redact sensitive numeric data,
|
@@ -370,15 +372,18 @@ module IBMWatson
|
|
370
372
|
#
|
371
373
|
# See [Numeric
|
372
374
|
# redaction](https://cloud.ibm.com/docs/services/speech-to-text/output.html#redaction).
|
375
|
+
# @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
|
376
|
+
# audio format, see **Audio formats (content types)** in the method description.
|
373
377
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
374
|
-
def recognize(audio:,
|
378
|
+
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, content_type: nil)
|
375
379
|
raise ArgumentError.new("audio must be provided") if audio.nil?
|
376
380
|
|
377
381
|
headers = {
|
378
382
|
"Content-Type" => content_type
|
379
383
|
}
|
380
384
|
keywords *= "," unless keywords.nil?
|
381
|
-
|
385
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "recognize")
|
386
|
+
headers.merge!(sdk_headers)
|
382
387
|
|
383
388
|
params = {
|
384
389
|
"model" => model,
|
@@ -492,9 +497,7 @@ module IBMWatson
|
|
492
497
|
raise TypeError("Callback is not a derived class of RecognizeCallback") unless recognize_callback.is_a?(IBMWatson::RecognizeCallback)
|
493
498
|
|
494
499
|
require_relative("./websocket/speech_to_text_websocket_listener.rb")
|
495
|
-
headers = {
|
496
|
-
}
|
497
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "recognize_using_websocket")
|
500
|
+
headers = {}
|
498
501
|
headers = conn.default_options.headers.to_hash unless conn.default_options.headers.to_hash.empty?
|
499
502
|
if !token_manager.nil?
|
500
503
|
access_token = token_manager.token
|
@@ -587,113 +590,79 @@ module IBMWatson
|
|
587
590
|
#########################
|
588
591
|
|
589
592
|
##
|
590
|
-
# @!method
|
591
|
-
#
|
592
|
-
#
|
593
|
-
#
|
594
|
-
#
|
595
|
-
#
|
596
|
-
#
|
597
|
-
# header that specifies `text/plain` as the required response type.
|
598
|
-
#
|
599
|
-
# To be registered successfully, the callback URL must respond to the `GET` request
|
600
|
-
# from the service. The response must send status code 200 and must include the
|
601
|
-
# challenge string in its body. Set the `Content-Type` response header to
|
602
|
-
# `text/plain`. Upon receiving this response, the service responds to the original
|
603
|
-
# registration request with response code 201.
|
604
|
-
#
|
605
|
-
# The service sends only a single `GET` request to the callback URL. If the service
|
606
|
-
# does not receive a reply with a response code of 200 and a body that echoes the
|
607
|
-
# challenge string sent by the service within five seconds, it does not white-list
|
608
|
-
# the URL; it instead sends status code 400 in response to the **Register a
|
609
|
-
# callback** request. If the requested callback URL is already white-listed, the
|
610
|
-
# service responds to the initial registration request with response code 200.
|
611
|
-
#
|
612
|
-
# If you specify a user secret with the request, the service uses it as a key to
|
613
|
-
# calculate an HMAC-SHA1 signature of the challenge string in its response to the
|
614
|
-
# `POST` request. It sends this signature in the `X-Callback-Signature` header of
|
615
|
-
# its `GET` request to the URL during registration. It also uses the secret to
|
616
|
-
# calculate a signature over the payload of every callback notification that uses
|
617
|
-
# the URL. The signature provides authentication and data integrity for HTTP
|
618
|
-
# communications.
|
593
|
+
# @!method check_job(id:)
|
594
|
+
# Check a job.
|
595
|
+
# Returns information about the specified job. The response always includes the
|
596
|
+
# status of the job and its creation and update times. If the status is `completed`,
|
597
|
+
# the response includes the results of the recognition request. You must use
|
598
|
+
# credentials for the instance of the service that owns a job to list information
|
599
|
+
# about it.
|
619
600
|
#
|
620
|
-
#
|
621
|
-
#
|
622
|
-
#
|
601
|
+
# You can use the method to retrieve the results of any job, regardless of whether
|
602
|
+
# it was submitted with a callback URL and the `recognitions.completed_with_results`
|
603
|
+
# event, and you can retrieve the results multiple times for as long as they remain
|
604
|
+
# available. Use the **Check jobs** method to request information about the most
|
605
|
+
# recent jobs associated with the calling credentials.
|
623
606
|
#
|
624
|
-
# **See also:** [
|
625
|
-
#
|
626
|
-
# @param
|
627
|
-
#
|
628
|
-
#
|
629
|
-
# the service sends in the `X-Callback-Signature` header to verify the origin of the
|
630
|
-
# request.
|
631
|
-
# @param user_secret [String] A user-specified string that the service uses to generate the HMAC-SHA1 signature
|
632
|
-
# that it sends via the `X-Callback-Signature` header. The service includes the
|
633
|
-
# header during URL verification and with every notification sent to the callback
|
634
|
-
# URL. It calculates the signature over the payload of the notification. If you omit
|
635
|
-
# the parameter, the service does not send the header.
|
607
|
+
# **See also:** [Checking the status and retrieving the results of a
|
608
|
+
# job](https://cloud.ibm.com/docs/services/speech-to-text/async.html#job).
|
609
|
+
# @param id [String] The identifier of the asynchronous job that is to be used for the request. You
|
610
|
+
# must make the request with credentials for the instance of the service that owns
|
611
|
+
# the job.
|
636
612
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
637
|
-
def
|
638
|
-
raise ArgumentError.new("
|
613
|
+
def check_job(id:)
|
614
|
+
raise ArgumentError.new("id must be provided") if id.nil?
|
639
615
|
|
640
616
|
headers = {
|
641
617
|
}
|
642
|
-
|
643
|
-
|
644
|
-
params = {
|
645
|
-
"callback_url" => callback_url,
|
646
|
-
"user_secret" => user_secret
|
647
|
-
}
|
618
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "check_job")
|
619
|
+
headers.merge!(sdk_headers)
|
648
620
|
|
649
|
-
method_url = "/v1/
|
621
|
+
method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
|
650
622
|
|
651
623
|
response = request(
|
652
|
-
method: "
|
624
|
+
method: "GET",
|
653
625
|
url: method_url,
|
654
626
|
headers: headers,
|
655
|
-
params: params,
|
656
627
|
accept_json: true
|
657
628
|
)
|
658
629
|
response
|
659
630
|
end
|
660
631
|
|
661
632
|
##
|
662
|
-
# @!method
|
663
|
-
#
|
664
|
-
#
|
665
|
-
#
|
666
|
-
#
|
633
|
+
# @!method check_jobs
|
634
|
+
# Check jobs.
|
635
|
+
# Returns the ID and status of the latest 100 outstanding jobs associated with the
|
636
|
+
# credentials with which it is called. The method also returns the creation and
|
637
|
+
# update times of each job, and, if a job was created with a callback URL and a user
|
638
|
+
# token, the user token for the job. To obtain the results for a job whose status is
|
639
|
+
# `completed` or not one of the latest 100 outstanding jobs, use the **Check a job**
|
640
|
+
# method. A job and its results remain available until you delete them with the
|
641
|
+
# **Delete a job** method or until the job's time to live expires, whichever comes
|
642
|
+
# first.
|
667
643
|
#
|
668
|
-
# **See also:** [
|
669
|
-
#
|
670
|
-
# @
|
671
|
-
|
672
|
-
def unregister_callback(callback_url:)
|
673
|
-
raise ArgumentError.new("callback_url must be provided") if callback_url.nil?
|
674
|
-
|
644
|
+
# **See also:** [Checking the status of the latest
|
645
|
+
# jobs](https://cloud.ibm.com/docs/services/speech-to-text/async.html#jobs).
|
646
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
647
|
+
def check_jobs
|
675
648
|
headers = {
|
676
649
|
}
|
677
|
-
|
678
|
-
|
679
|
-
params = {
|
680
|
-
"callback_url" => callback_url
|
681
|
-
}
|
650
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "check_jobs")
|
651
|
+
headers.merge!(sdk_headers)
|
682
652
|
|
683
|
-
method_url = "/v1/
|
653
|
+
method_url = "/v1/recognitions"
|
684
654
|
|
685
|
-
request(
|
686
|
-
method: "
|
655
|
+
response = request(
|
656
|
+
method: "GET",
|
687
657
|
url: method_url,
|
688
658
|
headers: headers,
|
689
|
-
params: params,
|
690
659
|
accept_json: true
|
691
660
|
)
|
692
|
-
|
661
|
+
response
|
693
662
|
end
|
694
663
|
|
695
664
|
##
|
696
|
-
# @!method create_job(audio:,
|
665
|
+
# @!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, content_type: nil)
|
697
666
|
# Create a job.
|
698
667
|
# Creates a job for a new asynchronous recognition request. The job is owned by the
|
699
668
|
# instance of the service whose credentials are used to create it. How you learn the
|
@@ -725,10 +694,10 @@ module IBMWatson
|
|
725
694
|
# * `user_token`
|
726
695
|
# * `results_ttl`
|
727
696
|
#
|
728
|
-
# You can pass a maximum of
|
729
|
-
#
|
730
|
-
#
|
731
|
-
#
|
697
|
+
# You can pass a maximum of 1 GB and a minimum of 100 bytes of audio with a request.
|
698
|
+
# The service automatically detects the endianness of the incoming audio and, for
|
699
|
+
# audio that includes multiple channels, downmixes the audio to one-channel mono
|
700
|
+
# during transcoding. The method returns only final results; to enable interim
|
732
701
|
# results, use the WebSocket API.
|
733
702
|
#
|
734
703
|
# **See also:** [Creating a
|
@@ -738,11 +707,11 @@ module IBMWatson
|
|
738
707
|
#
|
739
708
|
# For requests to transcribe live audio as it becomes available, you must set the
|
740
709
|
# `Transfer-Encoding` header to `chunked` to use streaming mode. In streaming mode,
|
741
|
-
# the
|
742
|
-
#
|
743
|
-
# also closes the connection (status code 400) if no speech
|
744
|
-
# `inactivity_timeout` seconds of audio
|
745
|
-
#
|
710
|
+
# the service closes the connection (status code 408) if it does not receive at
|
711
|
+
# least 15 seconds of audio (including silence) in any 30-second period. The service
|
712
|
+
# also closes the connection (status code 400) if it detects no speech for
|
713
|
+
# `inactivity_timeout` seconds of streaming audio; use the `inactivity_timeout`
|
714
|
+
# parameter to change the default of 30 seconds.
|
746
715
|
#
|
747
716
|
# **See also:**
|
748
717
|
# * [Audio
|
@@ -763,6 +732,7 @@ module IBMWatson
|
|
763
732
|
#
|
764
733
|
# Where indicated, the format that you specify must include the sampling rate and
|
765
734
|
# can optionally include the number of channels and the endianness of the audio.
|
735
|
+
# * `audio/alaw` (**Required.** Specify the sampling rate (`rate`) of the audio.)
|
766
736
|
# * `audio/basic` (**Required.** Use only with narrowband models.)
|
767
737
|
# * `audio/flac`
|
768
738
|
# * `audio/g729` (Use only with narrowband models.)
|
@@ -789,8 +759,6 @@ module IBMWatson
|
|
789
759
|
# **See also:** [Audio
|
790
760
|
# formats](https://cloud.ibm.com/docs/services/speech-to-text/audio-formats.html).
|
791
761
|
# @param audio [String] The audio to transcribe.
|
792
|
-
# @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
|
793
|
-
# audio format, see **Audio formats (content types)** in the method description.
|
794
762
|
# @param model [String] The identifier of the model that is to be used for the recognition request. See
|
795
763
|
# [Languages and
|
796
764
|
# models](https://cloud.ibm.com/docs/services/speech-to-text/models.html).
|
@@ -833,7 +801,8 @@ module IBMWatson
|
|
833
801
|
# match the model specified with the `model` parameter. You must make the request
|
834
802
|
# with credentials for the instance of the service that owns the custom model. By
|
835
803
|
# default, no custom language model is used. See [Custom
|
836
|
-
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom).
|
804
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom-input).
|
805
|
+
#
|
837
806
|
#
|
838
807
|
# **Note:** Use this parameter instead of the deprecated `customization_id`
|
839
808
|
# parameter.
|
@@ -842,7 +811,7 @@ module IBMWatson
|
|
842
811
|
# match the model specified with the `model` parameter. You must make the request
|
843
812
|
# with credentials for the instance of the service that owns the custom model. By
|
844
813
|
# default, no custom acoustic model is used. See [Custom
|
845
|
-
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom).
|
814
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom-input).
|
846
815
|
# @param base_model_version [String] The version of the specified base model that is to be used with recognition
|
847
816
|
# request. Multiple versions of a base model can exist when a model is updated for
|
848
817
|
# internal improvements. The parameter is intended primarily for use with custom
|
@@ -866,12 +835,12 @@ module IBMWatson
|
|
866
835
|
# phrases.
|
867
836
|
#
|
868
837
|
# See [Custom
|
869
|
-
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom).
|
838
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/input.html#custom-input).
|
870
839
|
# @param inactivity_timeout [Fixnum] The time in seconds after which, if only silence (no speech) is detected in
|
871
|
-
#
|
840
|
+
# streaming audio, the connection is closed with a 400 error. The parameter is
|
872
841
|
# useful for stopping audio submission from a live microphone when a user simply
|
873
|
-
# walks away. Use `-1` for infinity. See
|
874
|
-
#
|
842
|
+
# walks away. Use `-1` for infinity. See [Inactivity
|
843
|
+
# timeout](https://cloud.ibm.com/docs/services/speech-to-text/input.html#timeouts-inactivity).
|
875
844
|
# @param keywords [Array[String]] An array of keyword strings to spot in the audio. Each keyword string can include
|
876
845
|
# one or more string tokens. Keywords are spotted only in the final results, not in
|
877
846
|
# interim hypotheses. If you specify any keywords, you must also specify a keywords
|
@@ -885,7 +854,8 @@ module IBMWatson
|
|
885
854
|
# spotting if you omit either parameter. See [Keyword
|
886
855
|
# spotting](https://cloud.ibm.com/docs/services/speech-to-text/output.html#keyword_spotting).
|
887
856
|
# @param max_alternatives [Fixnum] The maximum number of alternative transcripts that the service is to return. By
|
888
|
-
# default, the service returns a single transcript.
|
857
|
+
# default, the service returns a single transcript. If you specify a value of `0`,
|
858
|
+
# the service uses the default value, `1`. See [Maximum
|
889
859
|
# alternatives](https://cloud.ibm.com/docs/services/speech-to-text/output.html#max_alternatives).
|
890
860
|
# @param word_alternatives_threshold [Float] A confidence value that is the lower bound for identifying a hypothesis as a
|
891
861
|
# possible word alternative (also known as \"Confusion Networks\"). An alternative
|
@@ -935,7 +905,7 @@ module IBMWatson
|
|
935
905
|
# specify the name of the custom language model for which the grammar is defined.
|
936
906
|
# The service recognizes only strings that are recognized by the specified grammar;
|
937
907
|
# it does not recognize other custom words from the model's words resource. See
|
938
|
-
# [Grammars](https://cloud.ibm.com/docs/services/speech-to-text/
|
908
|
+
# [Grammars](https://cloud.ibm.com/docs/services/speech-to-text/input.html#grammars-input).
|
939
909
|
# @param redaction [Boolean] If `true`, the service redacts, or masks, numeric data from final transcripts. The
|
940
910
|
# feature redacts any number that has three or more consecutive digits by replacing
|
941
911
|
# each digit with an `X` character. It is intended to redact sensitive numeric data,
|
@@ -951,14 +921,17 @@ module IBMWatson
|
|
951
921
|
#
|
952
922
|
# See [Numeric
|
953
923
|
# redaction](https://cloud.ibm.com/docs/services/speech-to-text/output.html#redaction).
|
924
|
+
# @param content_type [String] The format (MIME type) of the audio. For more information about specifying an
|
925
|
+
# audio format, see **Audio formats (content types)** in the method description.
|
954
926
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
955
|
-
def create_job(audio:,
|
927
|
+
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, content_type: nil)
|
956
928
|
raise ArgumentError.new("audio must be provided") if audio.nil?
|
957
929
|
|
958
930
|
headers = {
|
959
931
|
"Content-Type" => content_type
|
960
932
|
}
|
961
|
-
|
933
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "create_job")
|
934
|
+
headers.merge!(sdk_headers)
|
962
935
|
|
963
936
|
params = {
|
964
937
|
"model" => model,
|
@@ -1000,76 +973,6 @@ module IBMWatson
|
|
1000
973
|
response
|
1001
974
|
end
|
1002
975
|
|
1003
|
-
##
|
1004
|
-
# @!method check_jobs
|
1005
|
-
# Check jobs.
|
1006
|
-
# Returns the ID and status of the latest 100 outstanding jobs associated with the
|
1007
|
-
# credentials with which it is called. The method also returns the creation and
|
1008
|
-
# update times of each job, and, if a job was created with a callback URL and a user
|
1009
|
-
# token, the user token for the job. To obtain the results for a job whose status is
|
1010
|
-
# `completed` or not one of the latest 100 outstanding jobs, use the **Check a job**
|
1011
|
-
# method. A job and its results remain available until you delete them with the
|
1012
|
-
# **Delete a job** method or until the job's time to live expires, whichever comes
|
1013
|
-
# first.
|
1014
|
-
#
|
1015
|
-
# **See also:** [Checking the status of the latest
|
1016
|
-
# jobs](https://cloud.ibm.com/docs/services/speech-to-text/async.html#jobs).
|
1017
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1018
|
-
def check_jobs
|
1019
|
-
headers = {
|
1020
|
-
}
|
1021
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "check_jobs")
|
1022
|
-
|
1023
|
-
method_url = "/v1/recognitions"
|
1024
|
-
|
1025
|
-
response = request(
|
1026
|
-
method: "GET",
|
1027
|
-
url: method_url,
|
1028
|
-
headers: headers,
|
1029
|
-
accept_json: true
|
1030
|
-
)
|
1031
|
-
response
|
1032
|
-
end
|
1033
|
-
|
1034
|
-
##
|
1035
|
-
# @!method check_job(id:)
|
1036
|
-
# Check a job.
|
1037
|
-
# Returns information about the specified job. The response always includes the
|
1038
|
-
# status of the job and its creation and update times. If the status is `completed`,
|
1039
|
-
# the response includes the results of the recognition request. You must use
|
1040
|
-
# credentials for the instance of the service that owns a job to list information
|
1041
|
-
# about it.
|
1042
|
-
#
|
1043
|
-
# You can use the method to retrieve the results of any job, regardless of whether
|
1044
|
-
# it was submitted with a callback URL and the `recognitions.completed_with_results`
|
1045
|
-
# event, and you can retrieve the results multiple times for as long as they remain
|
1046
|
-
# available. Use the **Check jobs** method to request information about the most
|
1047
|
-
# recent jobs associated with the calling credentials.
|
1048
|
-
#
|
1049
|
-
# **See also:** [Checking the status and retrieving the results of a
|
1050
|
-
# job](https://cloud.ibm.com/docs/services/speech-to-text/async.html#job).
|
1051
|
-
# @param id [String] The identifier of the asynchronous job that is to be used for the request. You
|
1052
|
-
# must make the request with credentials for the instance of the service that owns
|
1053
|
-
# the job.
|
1054
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1055
|
-
def check_job(id:)
|
1056
|
-
raise ArgumentError.new("id must be provided") if id.nil?
|
1057
|
-
|
1058
|
-
headers = {
|
1059
|
-
}
|
1060
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "check_job")
|
1061
|
-
|
1062
|
-
method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
|
1063
|
-
|
1064
|
-
response = request(
|
1065
|
-
method: "GET",
|
1066
|
-
url: method_url,
|
1067
|
-
headers: headers,
|
1068
|
-
accept_json: true
|
1069
|
-
)
|
1070
|
-
response
|
1071
|
-
end
|
1072
|
-
|
1073
976
|
##
|
1074
977
|
# @!method delete_job(id:)
|
1075
978
|
# Delete a job.
|
@@ -1080,7 +983,7 @@ module IBMWatson
|
|
1080
983
|
# owns a job to delete it.
|
1081
984
|
#
|
1082
985
|
# **See also:** [Deleting a
|
1083
|
-
# job](https://cloud.ibm.com/docs/services/speech-to-text/async.html#delete).
|
986
|
+
# job](https://cloud.ibm.com/docs/services/speech-to-text/async.html#delete-async).
|
1084
987
|
# @param id [String] The identifier of the asynchronous job that is to be used for the request. You
|
1085
988
|
# must make the request with credentials for the instance of the service that owns
|
1086
989
|
# the job.
|
@@ -1090,7 +993,8 @@ module IBMWatson
|
|
1090
993
|
|
1091
994
|
headers = {
|
1092
995
|
}
|
1093
|
-
|
996
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "delete_job")
|
997
|
+
headers.merge!(sdk_headers)
|
1094
998
|
|
1095
999
|
method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
|
1096
1000
|
|
@@ -1098,28 +1002,136 @@ module IBMWatson
|
|
1098
1002
|
method: "DELETE",
|
1099
1003
|
url: method_url,
|
1100
1004
|
headers: headers,
|
1101
|
-
accept_json:
|
1005
|
+
accept_json: false
|
1102
1006
|
)
|
1103
1007
|
nil
|
1104
1008
|
end
|
1105
|
-
#########################
|
1106
|
-
# Custom language models
|
1107
|
-
#########################
|
1108
1009
|
|
1109
1010
|
##
|
1110
|
-
# @!method
|
1111
|
-
#
|
1112
|
-
#
|
1113
|
-
#
|
1114
|
-
#
|
1115
|
-
#
|
1011
|
+
# @!method register_callback(callback_url:, user_secret: nil)
|
1012
|
+
# Register a callback.
|
1013
|
+
# Registers a callback URL with the service for use with subsequent asynchronous
|
1014
|
+
# recognition requests. The service attempts to register, or white-list, the
|
1015
|
+
# callback URL if it is not already registered by sending a `GET` request to the
|
1016
|
+
# callback URL. The service passes a random alphanumeric challenge string via the
|
1017
|
+
# `challenge_string` parameter of the request. The request includes an `Accept`
|
1018
|
+
# header that specifies `text/plain` as the required response type.
|
1116
1019
|
#
|
1117
|
-
#
|
1118
|
-
#
|
1119
|
-
#
|
1120
|
-
#
|
1121
|
-
#
|
1122
|
-
#
|
1020
|
+
# To be registered successfully, the callback URL must respond to the `GET` request
|
1021
|
+
# from the service. The response must send status code 200 and must include the
|
1022
|
+
# challenge string in its body. Set the `Content-Type` response header to
|
1023
|
+
# `text/plain`. Upon receiving this response, the service responds to the original
|
1024
|
+
# registration request with response code 201.
|
1025
|
+
#
|
1026
|
+
# The service sends only a single `GET` request to the callback URL. If the service
|
1027
|
+
# does not receive a reply with a response code of 200 and a body that echoes the
|
1028
|
+
# challenge string sent by the service within five seconds, it does not white-list
|
1029
|
+
# the URL; it instead sends status code 400 in response to the **Register a
|
1030
|
+
# callback** request. If the requested callback URL is already white-listed, the
|
1031
|
+
# service responds to the initial registration request with response code 200.
|
1032
|
+
#
|
1033
|
+
# If you specify a user secret with the request, the service uses it as a key to
|
1034
|
+
# calculate an HMAC-SHA1 signature of the challenge string in its response to the
|
1035
|
+
# `POST` request. It sends this signature in the `X-Callback-Signature` header of
|
1036
|
+
# its `GET` request to the URL during registration. It also uses the secret to
|
1037
|
+
# calculate a signature over the payload of every callback notification that uses
|
1038
|
+
# the URL. The signature provides authentication and data integrity for HTTP
|
1039
|
+
# communications.
|
1040
|
+
#
|
1041
|
+
# After you successfully register a callback URL, you can use it with an indefinite
|
1042
|
+
# number of recognition requests. You can register a maximum of 20 callback URLS in
|
1043
|
+
# a one-hour span of time.
|
1044
|
+
#
|
1045
|
+
# **See also:** [Registering a callback
|
1046
|
+
# URL](https://cloud.ibm.com/docs/services/speech-to-text/async.html#register).
|
1047
|
+
# @param callback_url [String] An HTTP or HTTPS URL to which callback notifications are to be sent. To be
|
1048
|
+
# white-listed, the URL must successfully echo the challenge string during URL
|
1049
|
+
# verification. During verification, the client can also check the signature that
|
1050
|
+
# the service sends in the `X-Callback-Signature` header to verify the origin of the
|
1051
|
+
# request.
|
1052
|
+
# @param user_secret [String] A user-specified string that the service uses to generate the HMAC-SHA1 signature
|
1053
|
+
# that it sends via the `X-Callback-Signature` header. The service includes the
|
1054
|
+
# header during URL verification and with every notification sent to the callback
|
1055
|
+
# URL. It calculates the signature over the payload of the notification. If you omit
|
1056
|
+
# the parameter, the service does not send the header.
|
1057
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1058
|
+
def register_callback(callback_url:, user_secret: nil)
|
1059
|
+
raise ArgumentError.new("callback_url must be provided") if callback_url.nil?
|
1060
|
+
|
1061
|
+
headers = {
|
1062
|
+
}
|
1063
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "register_callback")
|
1064
|
+
headers.merge!(sdk_headers)
|
1065
|
+
|
1066
|
+
params = {
|
1067
|
+
"callback_url" => callback_url,
|
1068
|
+
"user_secret" => user_secret
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
method_url = "/v1/register_callback"
|
1072
|
+
|
1073
|
+
response = request(
|
1074
|
+
method: "POST",
|
1075
|
+
url: method_url,
|
1076
|
+
headers: headers,
|
1077
|
+
params: params,
|
1078
|
+
accept_json: true
|
1079
|
+
)
|
1080
|
+
response
|
1081
|
+
end
|
1082
|
+
|
1083
|
+
##
|
1084
|
+
# @!method unregister_callback(callback_url:)
|
1085
|
+
# Unregister a callback.
|
1086
|
+
# Unregisters a callback URL that was previously white-listed with a **Register a
|
1087
|
+
# callback** request for use with the asynchronous interface. Once unregistered, the
|
1088
|
+
# URL can no longer be used with asynchronous recognition requests.
|
1089
|
+
#
|
1090
|
+
# **See also:** [Unregistering a callback
|
1091
|
+
# URL](https://cloud.ibm.com/docs/services/speech-to-text/async.html#unregister).
|
1092
|
+
# @param callback_url [String] The callback URL that is to be unregistered.
|
1093
|
+
# @return [nil]
|
1094
|
+
def unregister_callback(callback_url:)
|
1095
|
+
raise ArgumentError.new("callback_url must be provided") if callback_url.nil?
|
1096
|
+
|
1097
|
+
headers = {
|
1098
|
+
}
|
1099
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "unregister_callback")
|
1100
|
+
headers.merge!(sdk_headers)
|
1101
|
+
|
1102
|
+
params = {
|
1103
|
+
"callback_url" => callback_url
|
1104
|
+
}
|
1105
|
+
|
1106
|
+
method_url = "/v1/unregister_callback"
|
1107
|
+
|
1108
|
+
request(
|
1109
|
+
method: "POST",
|
1110
|
+
url: method_url,
|
1111
|
+
headers: headers,
|
1112
|
+
params: params,
|
1113
|
+
accept_json: false
|
1114
|
+
)
|
1115
|
+
nil
|
1116
|
+
end
|
1117
|
+
#########################
|
1118
|
+
# Custom language models
|
1119
|
+
#########################
|
1120
|
+
|
1121
|
+
##
|
1122
|
+
# @!method create_language_model(name:, base_model_name:, dialect: nil, description: nil)
|
1123
|
+
# Create a custom language model.
|
1124
|
+
# Creates a new custom language model for a specified base model. The custom
|
1125
|
+
# language model can be used only with the base model for which it is created. The
|
1126
|
+
# model is owned by the instance of the service whose credentials are used to create
|
1127
|
+
# it.
|
1128
|
+
#
|
1129
|
+
# **See also:** [Create a custom language
|
1130
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-create.html#createModel-language).
|
1131
|
+
# @param name [String] A user-defined name for the new custom language model. Use a name that is unique
|
1132
|
+
# among all custom language models that you own. Use a localized name that matches
|
1133
|
+
# the language of the custom model. Use a name that describes the domain of the
|
1134
|
+
# custom model, such as `Medical custom model` or `Legal custom model`.
|
1123
1135
|
# @param base_model_name [String] The name of the base language model that is to be customized by the new custom
|
1124
1136
|
# language model. The new custom model can be used only with the base model that it
|
1125
1137
|
# customizes.
|
@@ -1149,7 +1161,8 @@ module IBMWatson
|
|
1149
1161
|
|
1150
1162
|
headers = {
|
1151
1163
|
}
|
1152
|
-
|
1164
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "create_language_model")
|
1165
|
+
headers.merge!(sdk_headers)
|
1153
1166
|
|
1154
1167
|
data = {
|
1155
1168
|
"name" => name,
|
@@ -1171,39 +1184,36 @@ module IBMWatson
|
|
1171
1184
|
end
|
1172
1185
|
|
1173
1186
|
##
|
1174
|
-
# @!method
|
1175
|
-
#
|
1176
|
-
#
|
1177
|
-
#
|
1178
|
-
#
|
1179
|
-
#
|
1180
|
-
# a model to list information about it.
|
1187
|
+
# @!method delete_language_model(customization_id:)
|
1188
|
+
# Delete a custom language model.
|
1189
|
+
# Deletes an existing custom language model. The custom model cannot be deleted if
|
1190
|
+
# another request, such as adding a corpus or grammar to the model, is currently
|
1191
|
+
# being processed. You must use credentials for the instance of the service that
|
1192
|
+
# owns a model to delete it.
|
1181
1193
|
#
|
1182
|
-
# **See also:** [
|
1183
|
-
#
|
1184
|
-
# @param
|
1185
|
-
#
|
1186
|
-
#
|
1187
|
-
# @return [
|
1188
|
-
def
|
1189
|
-
|
1190
|
-
}
|
1191
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "list_language_models")
|
1194
|
+
# **See also:** [Deleting a custom language
|
1195
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-models.html#deleteModel-language).
|
1196
|
+
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1197
|
+
# the request. You must make the request with credentials for the instance of the
|
1198
|
+
# service that owns the custom model.
|
1199
|
+
# @return [nil]
|
1200
|
+
def delete_language_model(customization_id:)
|
1201
|
+
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1192
1202
|
|
1193
|
-
|
1194
|
-
"language" => language
|
1203
|
+
headers = {
|
1195
1204
|
}
|
1205
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "delete_language_model")
|
1206
|
+
headers.merge!(sdk_headers)
|
1196
1207
|
|
1197
|
-
method_url = "/v1/customizations"
|
1208
|
+
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
1198
1209
|
|
1199
|
-
|
1200
|
-
method: "
|
1210
|
+
request(
|
1211
|
+
method: "DELETE",
|
1201
1212
|
url: method_url,
|
1202
1213
|
headers: headers,
|
1203
|
-
params: params,
|
1204
1214
|
accept_json: true
|
1205
1215
|
)
|
1206
|
-
|
1216
|
+
nil
|
1207
1217
|
end
|
1208
1218
|
|
1209
1219
|
##
|
@@ -1213,7 +1223,7 @@ module IBMWatson
|
|
1213
1223
|
# for the instance of the service that owns a model to list information about it.
|
1214
1224
|
#
|
1215
1225
|
# **See also:** [Listing custom language
|
1216
|
-
# models](https://cloud.ibm.com/docs/services/speech-to-text/language-models.html#listModels).
|
1226
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/language-models.html#listModels-language).
|
1217
1227
|
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1218
1228
|
# the request. You must make the request with credentials for the instance of the
|
1219
1229
|
# service that owns the custom model.
|
@@ -1223,7 +1233,8 @@ module IBMWatson
|
|
1223
1233
|
|
1224
1234
|
headers = {
|
1225
1235
|
}
|
1226
|
-
|
1236
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "get_language_model")
|
1237
|
+
headers.merge!(sdk_headers)
|
1227
1238
|
|
1228
1239
|
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
1229
1240
|
|
@@ -1237,30 +1248,70 @@ module IBMWatson
|
|
1237
1248
|
end
|
1238
1249
|
|
1239
1250
|
##
|
1240
|
-
# @!method
|
1241
|
-
#
|
1242
|
-
#
|
1243
|
-
#
|
1244
|
-
#
|
1245
|
-
#
|
1251
|
+
# @!method list_language_models(language: nil)
|
1252
|
+
# List custom language models.
|
1253
|
+
# Lists information about all custom language models that are owned by an instance
|
1254
|
+
# of the service. Use the `language` parameter to see all custom language models for
|
1255
|
+
# the specified language. Omit the parameter to see all custom language models for
|
1256
|
+
# all languages. You must use credentials for the instance of the service that owns
|
1257
|
+
# a model to list information about it.
|
1246
1258
|
#
|
1247
|
-
# **See also:** [
|
1248
|
-
#
|
1259
|
+
# **See also:** [Listing custom language
|
1260
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/language-models.html#listModels-language).
|
1261
|
+
# @param language [String] The identifier of the language for which custom language or custom acoustic models
|
1262
|
+
# are to be returned (for example, `en-US`). Omit the parameter to see all custom
|
1263
|
+
# language or custom acoustic models that are owned by the requesting credentials.
|
1264
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1265
|
+
def list_language_models(language: nil)
|
1266
|
+
headers = {
|
1267
|
+
}
|
1268
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "list_language_models")
|
1269
|
+
headers.merge!(sdk_headers)
|
1270
|
+
|
1271
|
+
params = {
|
1272
|
+
"language" => language
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
method_url = "/v1/customizations"
|
1276
|
+
|
1277
|
+
response = request(
|
1278
|
+
method: "GET",
|
1279
|
+
url: method_url,
|
1280
|
+
headers: headers,
|
1281
|
+
params: params,
|
1282
|
+
accept_json: true
|
1283
|
+
)
|
1284
|
+
response
|
1285
|
+
end
|
1286
|
+
|
1287
|
+
##
|
1288
|
+
# @!method reset_language_model(customization_id:)
|
1289
|
+
# Reset a custom language model.
|
1290
|
+
# Resets a custom language model by removing all corpora, grammars, and words from
|
1291
|
+
# the model. Resetting a custom language model initializes the model to its state
|
1292
|
+
# when it was first created. Metadata such as the name and language of the model are
|
1293
|
+
# preserved, but the model's words resource is removed and must be re-created. You
|
1294
|
+
# must use credentials for the instance of the service that owns a model to reset
|
1295
|
+
# it.
|
1296
|
+
#
|
1297
|
+
# **See also:** [Resetting a custom language
|
1298
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-models.html#resetModel-language).
|
1249
1299
|
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1250
1300
|
# the request. You must make the request with credentials for the instance of the
|
1251
1301
|
# service that owns the custom model.
|
1252
1302
|
# @return [nil]
|
1253
|
-
def
|
1303
|
+
def reset_language_model(customization_id:)
|
1254
1304
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1255
1305
|
|
1256
1306
|
headers = {
|
1257
1307
|
}
|
1258
|
-
|
1308
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "reset_language_model")
|
1309
|
+
headers.merge!(sdk_headers)
|
1259
1310
|
|
1260
|
-
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
1311
|
+
method_url = "/v1/customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
|
1261
1312
|
|
1262
1313
|
request(
|
1263
|
-
method: "
|
1314
|
+
method: "POST",
|
1264
1315
|
url: method_url,
|
1265
1316
|
headers: headers,
|
1266
1317
|
accept_json: true
|
@@ -1299,7 +1350,7 @@ module IBMWatson
|
|
1299
1350
|
# pronunciations that you must fix.
|
1300
1351
|
#
|
1301
1352
|
# **See also:** [Train the custom language
|
1302
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-create.html#trainModel).
|
1353
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-create.html#trainModel-language).
|
1303
1354
|
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1304
1355
|
# the request. You must make the request with credentials for the instance of the
|
1305
1356
|
# service that owns the custom model.
|
@@ -1331,7 +1382,8 @@ module IBMWatson
|
|
1331
1382
|
|
1332
1383
|
headers = {
|
1333
1384
|
}
|
1334
|
-
|
1385
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "train_language_model")
|
1386
|
+
headers.merge!(sdk_headers)
|
1335
1387
|
|
1336
1388
|
params = {
|
1337
1389
|
"word_type_to_add" => word_type_to_add,
|
@@ -1350,40 +1402,6 @@ module IBMWatson
|
|
1350
1402
|
nil
|
1351
1403
|
end
|
1352
1404
|
|
1353
|
-
##
|
1354
|
-
# @!method reset_language_model(customization_id:)
|
1355
|
-
# Reset a custom language model.
|
1356
|
-
# Resets a custom language model by removing all corpora, grammars, and words from
|
1357
|
-
# the model. Resetting a custom language model initializes the model to its state
|
1358
|
-
# when it was first created. Metadata such as the name and language of the model are
|
1359
|
-
# preserved, but the model's words resource is removed and must be re-created. You
|
1360
|
-
# must use credentials for the instance of the service that owns a model to reset
|
1361
|
-
# it.
|
1362
|
-
#
|
1363
|
-
# **See also:** [Resetting a custom language
|
1364
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-models.html#resetModel).
|
1365
|
-
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1366
|
-
# the request. You must make the request with credentials for the instance of the
|
1367
|
-
# service that owns the custom model.
|
1368
|
-
# @return [nil]
|
1369
|
-
def reset_language_model(customization_id:)
|
1370
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1371
|
-
|
1372
|
-
headers = {
|
1373
|
-
}
|
1374
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "reset_language_model")
|
1375
|
-
|
1376
|
-
method_url = "/v1/customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
|
1377
|
-
|
1378
|
-
request(
|
1379
|
-
method: "POST",
|
1380
|
-
url: method_url,
|
1381
|
-
headers: headers,
|
1382
|
-
accept_json: true
|
1383
|
-
)
|
1384
|
-
nil
|
1385
|
-
end
|
1386
|
-
|
1387
1405
|
##
|
1388
1406
|
# @!method upgrade_language_model(customization_id:)
|
1389
1407
|
# Upgrade a custom language model.
|
@@ -1414,7 +1432,8 @@ module IBMWatson
|
|
1414
1432
|
|
1415
1433
|
headers = {
|
1416
1434
|
}
|
1417
|
-
|
1435
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "upgrade_language_model")
|
1436
|
+
headers.merge!(sdk_headers)
|
1418
1437
|
|
1419
1438
|
method_url = "/v1/customizations/%s/upgrade_model" % [ERB::Util.url_encode(customization_id)]
|
1420
1439
|
|
@@ -1431,39 +1450,7 @@ module IBMWatson
|
|
1431
1450
|
#########################
|
1432
1451
|
|
1433
1452
|
##
|
1434
|
-
# @!method
|
1435
|
-
# List corpora.
|
1436
|
-
# Lists information about all corpora from a custom language model. The information
|
1437
|
-
# includes the total number of words and out-of-vocabulary (OOV) words, name, and
|
1438
|
-
# status of each corpus. You must use credentials for the instance of the service
|
1439
|
-
# that owns a model to list its corpora.
|
1440
|
-
#
|
1441
|
-
# **See also:** [Listing corpora for a custom language
|
1442
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-corpora.html#listCorpora).
|
1443
|
-
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1444
|
-
# the request. You must make the request with credentials for the instance of the
|
1445
|
-
# service that owns the custom model.
|
1446
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1447
|
-
def list_corpora(customization_id:)
|
1448
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1449
|
-
|
1450
|
-
headers = {
|
1451
|
-
}
|
1452
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "list_corpora")
|
1453
|
-
|
1454
|
-
method_url = "/v1/customizations/%s/corpora" % [ERB::Util.url_encode(customization_id)]
|
1455
|
-
|
1456
|
-
response = request(
|
1457
|
-
method: "GET",
|
1458
|
-
url: method_url,
|
1459
|
-
headers: headers,
|
1460
|
-
accept_json: true
|
1461
|
-
)
|
1462
|
-
response
|
1463
|
-
end
|
1464
|
-
|
1465
|
-
##
|
1466
|
-
# @!method add_corpus(customization_id:, corpus_name:, corpus_file:, allow_overwrite: nil, corpus_filename: nil)
|
1453
|
+
# @!method add_corpus(customization_id:, corpus_name:, corpus_file:, allow_overwrite: nil)
|
1467
1454
|
# Add a corpus.
|
1468
1455
|
# Adds a single corpus text file of new training data to a custom language model.
|
1469
1456
|
# Use multiple requests to submit multiple corpus text files. You must use
|
@@ -1537,9 +1524,8 @@ module IBMWatson
|
|
1537
1524
|
# @param allow_overwrite [Boolean] If `true`, the specified corpus overwrites an existing corpus with the same name.
|
1538
1525
|
# If `false`, the request fails if a corpus with the same name already exists. The
|
1539
1526
|
# parameter has no effect if a corpus with the same name does not already exist.
|
1540
|
-
# @param corpus_filename [String] The filename for corpus_file.
|
1541
1527
|
# @return [nil]
|
1542
|
-
def add_corpus(customization_id:, corpus_name:, corpus_file:, allow_overwrite: nil
|
1528
|
+
def add_corpus(customization_id:, corpus_name:, corpus_file:, allow_overwrite: nil)
|
1543
1529
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1544
1530
|
|
1545
1531
|
raise ArgumentError.new("corpus_name must be provided") if corpus_name.nil?
|
@@ -1548,7 +1534,8 @@ module IBMWatson
|
|
1548
1534
|
|
1549
1535
|
headers = {
|
1550
1536
|
}
|
1551
|
-
|
1537
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "add_corpus")
|
1538
|
+
headers.merge!(sdk_headers)
|
1552
1539
|
|
1553
1540
|
params = {
|
1554
1541
|
"allow_overwrite" => allow_overwrite
|
@@ -1559,8 +1546,7 @@ module IBMWatson
|
|
1559
1546
|
unless corpus_file.instance_of?(StringIO) || corpus_file.instance_of?(File)
|
1560
1547
|
corpus_file = corpus_file.respond_to?(:to_json) ? StringIO.new(corpus_file.to_json) : StringIO.new(corpus_file)
|
1561
1548
|
end
|
1562
|
-
|
1563
|
-
form_data[:corpus_file] = HTTP::FormData::File.new(corpus_file, content_type: "text/plain", filename: corpus_filename)
|
1549
|
+
form_data[:corpus_file] = HTTP::FormData::File.new(corpus_file, content_type: "text/plain", filename: corpus_file.respond_to?(:path) ? corpus_file.path : nil)
|
1564
1550
|
|
1565
1551
|
method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
|
1566
1552
|
|
@@ -1575,41 +1561,6 @@ module IBMWatson
|
|
1575
1561
|
nil
|
1576
1562
|
end
|
1577
1563
|
|
1578
|
-
##
|
1579
|
-
# @!method get_corpus(customization_id:, corpus_name:)
|
1580
|
-
# Get a corpus.
|
1581
|
-
# Gets information about a corpus from a custom language model. The information
|
1582
|
-
# includes the total number of words and out-of-vocabulary (OOV) words, name, and
|
1583
|
-
# status of the corpus. You must use credentials for the instance of the service
|
1584
|
-
# that owns a model to list its corpora.
|
1585
|
-
#
|
1586
|
-
# **See also:** [Listing corpora for a custom language
|
1587
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-corpora.html#listCorpora).
|
1588
|
-
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1589
|
-
# the request. You must make the request with credentials for the instance of the
|
1590
|
-
# service that owns the custom model.
|
1591
|
-
# @param corpus_name [String] The name of the corpus for the custom language model.
|
1592
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1593
|
-
def get_corpus(customization_id:, corpus_name:)
|
1594
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1595
|
-
|
1596
|
-
raise ArgumentError.new("corpus_name must be provided") if corpus_name.nil?
|
1597
|
-
|
1598
|
-
headers = {
|
1599
|
-
}
|
1600
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "get_corpus")
|
1601
|
-
|
1602
|
-
method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
|
1603
|
-
|
1604
|
-
response = request(
|
1605
|
-
method: "GET",
|
1606
|
-
url: method_url,
|
1607
|
-
headers: headers,
|
1608
|
-
accept_json: true
|
1609
|
-
)
|
1610
|
-
response
|
1611
|
-
end
|
1612
|
-
|
1613
1564
|
##
|
1614
1565
|
# @!method delete_corpus(customization_id:, corpus_name:)
|
1615
1566
|
# Delete a corpus.
|
@@ -1636,7 +1587,8 @@ module IBMWatson
|
|
1636
1587
|
|
1637
1588
|
headers = {
|
1638
1589
|
}
|
1639
|
-
|
1590
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "delete_corpus")
|
1591
|
+
headers.merge!(sdk_headers)
|
1640
1592
|
|
1641
1593
|
method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
|
1642
1594
|
|
@@ -1648,152 +1600,78 @@ module IBMWatson
|
|
1648
1600
|
)
|
1649
1601
|
nil
|
1650
1602
|
end
|
1651
|
-
#########################
|
1652
|
-
# Custom words
|
1653
|
-
#########################
|
1654
1603
|
|
1655
1604
|
##
|
1656
|
-
# @!method
|
1657
|
-
#
|
1658
|
-
#
|
1659
|
-
#
|
1660
|
-
#
|
1661
|
-
#
|
1662
|
-
# order in which the service is to return words; by default, the service lists words
|
1663
|
-
# in ascending alphabetical order. You must use credentials for the instance of the
|
1664
|
-
# service that owns a model to list information about its words.
|
1605
|
+
# @!method get_corpus(customization_id:, corpus_name:)
|
1606
|
+
# Get a corpus.
|
1607
|
+
# Gets information about a corpus from a custom language model. The information
|
1608
|
+
# includes the total number of words and out-of-vocabulary (OOV) words, name, and
|
1609
|
+
# status of the corpus. You must use credentials for the instance of the service
|
1610
|
+
# that owns a model to list its corpora.
|
1665
1611
|
#
|
1666
|
-
# **See also:** [Listing
|
1667
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-
|
1612
|
+
# **See also:** [Listing corpora for a custom language
|
1613
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-corpora.html#listCorpora).
|
1668
1614
|
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1669
1615
|
# the request. You must make the request with credentials for the instance of the
|
1670
1616
|
# service that owns the custom model.
|
1671
|
-
# @param
|
1672
|
-
# * `all` (the default) shows all words.
|
1673
|
-
# * `user` shows only custom words that were added or modified by the user directly.
|
1674
|
-
# * `corpora` shows only OOV that were extracted from corpora.
|
1675
|
-
# * `grammars` shows only OOV words that are recognized by grammars.
|
1676
|
-
# @param sort [String] Indicates the order in which the words are to be listed, `alphabetical` or by
|
1677
|
-
# `count`. You can prepend an optional `+` or `-` to an argument to indicate whether
|
1678
|
-
# the results are to be sorted in ascending or descending order. By default, words
|
1679
|
-
# are sorted in ascending alphabetical order. For alphabetical ordering, the
|
1680
|
-
# lexicographical precedence is numeric values, uppercase letters, and lowercase
|
1681
|
-
# letters. For count ordering, values with the same count are ordered
|
1682
|
-
# alphabetically. With the `curl` command, URL encode the `+` symbol as `%2B`.
|
1617
|
+
# @param corpus_name [String] The name of the corpus for the custom language model.
|
1683
1618
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1684
|
-
def
|
1619
|
+
def get_corpus(customization_id:, corpus_name:)
|
1685
1620
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1686
1621
|
|
1687
|
-
|
1688
|
-
}
|
1689
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "list_words")
|
1622
|
+
raise ArgumentError.new("corpus_name must be provided") if corpus_name.nil?
|
1690
1623
|
|
1691
|
-
|
1692
|
-
"word_type" => word_type,
|
1693
|
-
"sort" => sort
|
1624
|
+
headers = {
|
1694
1625
|
}
|
1626
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "get_corpus")
|
1627
|
+
headers.merge!(sdk_headers)
|
1695
1628
|
|
1696
|
-
method_url = "/v1/customizations/%s/
|
1629
|
+
method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
|
1697
1630
|
|
1698
1631
|
response = request(
|
1699
1632
|
method: "GET",
|
1700
1633
|
url: method_url,
|
1701
1634
|
headers: headers,
|
1702
|
-
params: params,
|
1703
1635
|
accept_json: true
|
1704
1636
|
)
|
1705
1637
|
response
|
1706
1638
|
end
|
1707
1639
|
|
1708
1640
|
##
|
1709
|
-
# @!method
|
1710
|
-
#
|
1711
|
-
#
|
1712
|
-
# the
|
1713
|
-
#
|
1714
|
-
#
|
1715
|
-
# resource for a model can contain a maximum of 30 thousand custom (OOV) words. This
|
1716
|
-
# includes words that the service extracts from corpora and grammars and words that
|
1717
|
-
# you add directly.
|
1718
|
-
#
|
1719
|
-
# You must use credentials for the instance of the service that owns a model to add
|
1720
|
-
# or modify custom words for the model. Adding or modifying custom words does not
|
1721
|
-
# affect the custom model until you train the model for the new data by using the
|
1722
|
-
# **Train a custom language model** method.
|
1723
|
-
#
|
1724
|
-
# You add custom words by providing a `CustomWords` object, which is an array of
|
1725
|
-
# `CustomWord` objects, one per word. You must use the object's `word` parameter to
|
1726
|
-
# identify the word that is to be added. You can also provide one or both of the
|
1727
|
-
# optional `sounds_like` and `display_as` fields for each word.
|
1728
|
-
# * The `sounds_like` field provides an array of one or more pronunciations for the
|
1729
|
-
# word. Use the parameter to specify how the word can be pronounced by users. Use
|
1730
|
-
# the parameter for words that are difficult to pronounce, foreign words, acronyms,
|
1731
|
-
# and so on. For example, you might specify that the word `IEEE` can sound like `i
|
1732
|
-
# triple e`. You can specify a maximum of five sounds-like pronunciations for a
|
1733
|
-
# word.
|
1734
|
-
# * The `display_as` field provides a different way of spelling the word in a
|
1735
|
-
# transcript. Use the parameter when you want the word to appear different from its
|
1736
|
-
# usual representation or from its spelling in training data. For example, you might
|
1737
|
-
# indicate that the word `IBM(trademark)` is to be displayed as `IBM™`.
|
1738
|
-
#
|
1739
|
-
# If you add a custom word that already exists in the words resource for the custom
|
1740
|
-
# model, the new definition overwrites the existing data for the word. If the
|
1741
|
-
# service encounters an error with the input data, it returns a failure code and
|
1742
|
-
# does not add any of the words to the words resource.
|
1743
|
-
#
|
1744
|
-
# The call returns an HTTP 201 response code if the input data is valid. It then
|
1745
|
-
# asynchronously processes the words to add them to the model's words resource. The
|
1746
|
-
# time that it takes for the analysis to complete depends on the number of new words
|
1747
|
-
# that you add but is generally faster than adding a corpus or grammar.
|
1748
|
-
#
|
1749
|
-
# You can monitor the status of the request by using the **List a custom language
|
1750
|
-
# model** method to poll the model's status. Use a loop to check the status every 10
|
1751
|
-
# seconds. The method returns a `Customization` object that includes a `status`
|
1752
|
-
# field. A status of `ready` means that the words have been added to the custom
|
1753
|
-
# model. The service cannot accept requests to add new data or to train the model
|
1754
|
-
# until the existing request completes.
|
1755
|
-
#
|
1756
|
-
# You can use the **List custom words** or **List a custom word** method to review
|
1757
|
-
# the words that you add. Words with an invalid `sounds_like` field include an
|
1758
|
-
# `error` field that describes the problem. You can use other words-related methods
|
1759
|
-
# to correct errors, eliminate typos, and modify how words are pronounced as needed.
|
1760
|
-
#
|
1641
|
+
# @!method list_corpora(customization_id:)
|
1642
|
+
# List corpora.
|
1643
|
+
# Lists information about all corpora from a custom language model. The information
|
1644
|
+
# includes the total number of words and out-of-vocabulary (OOV) words, name, and
|
1645
|
+
# status of each corpus. You must use credentials for the instance of the service
|
1646
|
+
# that owns a model to list its corpora.
|
1761
1647
|
#
|
1762
|
-
# **See also:**
|
1763
|
-
#
|
1764
|
-
# words](https://cloud.ibm.com/docs/services/speech-to-text/language-resource.html#workingWords)
|
1765
|
-
# * [Add words to the custom language
|
1766
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-create.html#addWords).
|
1648
|
+
# **See also:** [Listing corpora for a custom language
|
1649
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-corpora.html#listCorpora).
|
1767
1650
|
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1768
1651
|
# the request. You must make the request with credentials for the instance of the
|
1769
1652
|
# service that owns the custom model.
|
1770
|
-
# @
|
1771
|
-
|
1772
|
-
# @return [nil]
|
1773
|
-
def add_words(customization_id:, words:)
|
1653
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1654
|
+
def list_corpora(customization_id:)
|
1774
1655
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1775
1656
|
|
1776
|
-
raise ArgumentError.new("words must be provided") if words.nil?
|
1777
|
-
|
1778
1657
|
headers = {
|
1779
1658
|
}
|
1780
|
-
|
1659
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "list_corpora")
|
1660
|
+
headers.merge!(sdk_headers)
|
1781
1661
|
|
1782
|
-
|
1783
|
-
"words" => words
|
1784
|
-
}
|
1785
|
-
|
1786
|
-
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
1662
|
+
method_url = "/v1/customizations/%s/corpora" % [ERB::Util.url_encode(customization_id)]
|
1787
1663
|
|
1788
|
-
request(
|
1789
|
-
method: "
|
1664
|
+
response = request(
|
1665
|
+
method: "GET",
|
1790
1666
|
url: method_url,
|
1791
1667
|
headers: headers,
|
1792
|
-
json: data,
|
1793
1668
|
accept_json: true
|
1794
1669
|
)
|
1795
|
-
|
1670
|
+
response
|
1796
1671
|
end
|
1672
|
+
#########################
|
1673
|
+
# Custom words
|
1674
|
+
#########################
|
1797
1675
|
|
1798
1676
|
##
|
1799
1677
|
# @!method add_word(customization_id:, word_name:, word: nil, sounds_like: nil, display_as: nil)
|
@@ -1870,7 +1748,8 @@ module IBMWatson
|
|
1870
1748
|
|
1871
1749
|
headers = {
|
1872
1750
|
}
|
1873
|
-
|
1751
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "add_word")
|
1752
|
+
headers.merge!(sdk_headers)
|
1874
1753
|
|
1875
1754
|
data = {
|
1876
1755
|
"word" => word,
|
@@ -1891,39 +1770,94 @@ module IBMWatson
|
|
1891
1770
|
end
|
1892
1771
|
|
1893
1772
|
##
|
1894
|
-
# @!method
|
1895
|
-
#
|
1896
|
-
#
|
1897
|
-
#
|
1898
|
-
#
|
1773
|
+
# @!method add_words(customization_id:, words:)
|
1774
|
+
# Add custom words.
|
1775
|
+
# Adds one or more custom words to a custom language model. The service populates
|
1776
|
+
# the words resource for a custom model with out-of-vocabulary (OOV) words from each
|
1777
|
+
# corpus or grammar that is added to the model. You can use this method to add
|
1778
|
+
# additional words or to modify existing words in the words resource. The words
|
1779
|
+
# resource for a model can contain a maximum of 30 thousand custom (OOV) words. This
|
1780
|
+
# includes words that the service extracts from corpora and grammars and words that
|
1781
|
+
# you add directly.
|
1899
1782
|
#
|
1900
|
-
#
|
1901
|
-
# model
|
1783
|
+
# You must use credentials for the instance of the service that owns a model to add
|
1784
|
+
# or modify custom words for the model. Adding or modifying custom words does not
|
1785
|
+
# affect the custom model until you train the model for the new data by using the
|
1786
|
+
# **Train a custom language model** method.
|
1787
|
+
#
|
1788
|
+
# You add custom words by providing a `CustomWords` object, which is an array of
|
1789
|
+
# `CustomWord` objects, one per word. You must use the object's `word` parameter to
|
1790
|
+
# identify the word that is to be added. You can also provide one or both of the
|
1791
|
+
# optional `sounds_like` and `display_as` fields for each word.
|
1792
|
+
# * The `sounds_like` field provides an array of one or more pronunciations for the
|
1793
|
+
# word. Use the parameter to specify how the word can be pronounced by users. Use
|
1794
|
+
# the parameter for words that are difficult to pronounce, foreign words, acronyms,
|
1795
|
+
# and so on. For example, you might specify that the word `IEEE` can sound like `i
|
1796
|
+
# triple e`. You can specify a maximum of five sounds-like pronunciations for a
|
1797
|
+
# word.
|
1798
|
+
# * The `display_as` field provides a different way of spelling the word in a
|
1799
|
+
# transcript. Use the parameter when you want the word to appear different from its
|
1800
|
+
# usual representation or from its spelling in training data. For example, you might
|
1801
|
+
# indicate that the word `IBM(trademark)` is to be displayed as `IBM™`.
|
1802
|
+
#
|
1803
|
+
# If you add a custom word that already exists in the words resource for the custom
|
1804
|
+
# model, the new definition overwrites the existing data for the word. If the
|
1805
|
+
# service encounters an error with the input data, it returns a failure code and
|
1806
|
+
# does not add any of the words to the words resource.
|
1807
|
+
#
|
1808
|
+
# The call returns an HTTP 201 response code if the input data is valid. It then
|
1809
|
+
# asynchronously processes the words to add them to the model's words resource. The
|
1810
|
+
# time that it takes for the analysis to complete depends on the number of new words
|
1811
|
+
# that you add but is generally faster than adding a corpus or grammar.
|
1812
|
+
#
|
1813
|
+
# You can monitor the status of the request by using the **List a custom language
|
1814
|
+
# model** method to poll the model's status. Use a loop to check the status every 10
|
1815
|
+
# seconds. The method returns a `Customization` object that includes a `status`
|
1816
|
+
# field. A status of `ready` means that the words have been added to the custom
|
1817
|
+
# model. The service cannot accept requests to add new data or to train the model
|
1818
|
+
# until the existing request completes.
|
1819
|
+
#
|
1820
|
+
# You can use the **List custom words** or **List a custom word** method to review
|
1821
|
+
# the words that you add. Words with an invalid `sounds_like` field include an
|
1822
|
+
# `error` field that describes the problem. You can use other words-related methods
|
1823
|
+
# to correct errors, eliminate typos, and modify how words are pronounced as needed.
|
1824
|
+
#
|
1825
|
+
#
|
1826
|
+
# **See also:**
|
1827
|
+
# * [Working with custom
|
1828
|
+
# words](https://cloud.ibm.com/docs/services/speech-to-text/language-resource.html#workingWords)
|
1829
|
+
# * [Add words to the custom language
|
1830
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-create.html#addWords).
|
1902
1831
|
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1903
1832
|
# the request. You must make the request with credentials for the instance of the
|
1904
1833
|
# service that owns the custom model.
|
1905
|
-
# @param
|
1906
|
-
#
|
1907
|
-
#
|
1908
|
-
|
1909
|
-
def get_word(customization_id:, word_name:)
|
1834
|
+
# @param words [Array[CustomWord]] An array of `CustomWord` objects that provides information about each custom word
|
1835
|
+
# that is to be added to or updated in the custom language model.
|
1836
|
+
# @return [nil]
|
1837
|
+
def add_words(customization_id:, words:)
|
1910
1838
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1911
1839
|
|
1912
|
-
raise ArgumentError.new("
|
1840
|
+
raise ArgumentError.new("words must be provided") if words.nil?
|
1913
1841
|
|
1914
1842
|
headers = {
|
1915
1843
|
}
|
1916
|
-
|
1844
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "add_words")
|
1845
|
+
headers.merge!(sdk_headers)
|
1917
1846
|
|
1918
|
-
|
1847
|
+
data = {
|
1848
|
+
"words" => words
|
1849
|
+
}
|
1919
1850
|
|
1920
|
-
|
1921
|
-
|
1851
|
+
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
1852
|
+
|
1853
|
+
request(
|
1854
|
+
method: "POST",
|
1922
1855
|
url: method_url,
|
1923
1856
|
headers: headers,
|
1857
|
+
json: data,
|
1924
1858
|
accept_json: true
|
1925
1859
|
)
|
1926
|
-
|
1860
|
+
nil
|
1927
1861
|
end
|
1928
1862
|
|
1929
1863
|
##
|
@@ -1953,7 +1887,8 @@ module IBMWatson
|
|
1953
1887
|
|
1954
1888
|
headers = {
|
1955
1889
|
}
|
1956
|
-
|
1890
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "delete_word")
|
1891
|
+
headers.merge!(sdk_headers)
|
1957
1892
|
|
1958
1893
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
|
1959
1894
|
|
@@ -1965,41 +1900,100 @@ module IBMWatson
|
|
1965
1900
|
)
|
1966
1901
|
nil
|
1967
1902
|
end
|
1968
|
-
#########################
|
1969
|
-
# Custom grammars
|
1970
|
-
#########################
|
1971
1903
|
|
1972
1904
|
##
|
1973
|
-
# @!method
|
1974
|
-
#
|
1975
|
-
#
|
1976
|
-
#
|
1977
|
-
#
|
1978
|
-
# model to list its grammars.
|
1905
|
+
# @!method get_word(customization_id:, word_name:)
|
1906
|
+
# Get a custom word.
|
1907
|
+
# Gets information about a custom word from a custom language model. You must use
|
1908
|
+
# credentials for the instance of the service that owns a model to list information
|
1909
|
+
# about its words.
|
1979
1910
|
#
|
1980
|
-
# **See also:** [Listing
|
1981
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/).
|
1911
|
+
# **See also:** [Listing words from a custom language
|
1912
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-words.html#listWords).
|
1982
1913
|
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1983
1914
|
# the request. You must make the request with credentials for the instance of the
|
1984
1915
|
# service that owns the custom model.
|
1916
|
+
# @param word_name [String] The custom word that is to be read from the custom language model. URL-encode the
|
1917
|
+
# word if it includes non-ASCII characters. For more information, see [Character
|
1918
|
+
# encoding](https://cloud.ibm.com/docs/services/speech-to-text/language-resource.html#charEncoding).
|
1985
1919
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1986
|
-
def
|
1920
|
+
def get_word(customization_id:, word_name:)
|
1987
1921
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1988
1922
|
|
1923
|
+
raise ArgumentError.new("word_name must be provided") if word_name.nil?
|
1924
|
+
|
1989
1925
|
headers = {
|
1990
1926
|
}
|
1991
|
-
|
1927
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "get_word")
|
1928
|
+
headers.merge!(sdk_headers)
|
1992
1929
|
|
1993
|
-
method_url = "/v1/customizations/%s/
|
1930
|
+
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
|
1931
|
+
|
1932
|
+
response = request(
|
1933
|
+
method: "GET",
|
1934
|
+
url: method_url,
|
1935
|
+
headers: headers,
|
1936
|
+
accept_json: true
|
1937
|
+
)
|
1938
|
+
response
|
1939
|
+
end
|
1940
|
+
|
1941
|
+
##
|
1942
|
+
# @!method list_words(customization_id:, word_type: nil, sort: nil)
|
1943
|
+
# List custom words.
|
1944
|
+
# Lists information about custom words from a custom language model. You can list
|
1945
|
+
# all words from the custom model's words resource, only custom words that were
|
1946
|
+
# added or modified by the user, or only out-of-vocabulary (OOV) words that were
|
1947
|
+
# extracted from corpora or are recognized by grammars. You can also indicate the
|
1948
|
+
# order in which the service is to return words; by default, the service lists words
|
1949
|
+
# in ascending alphabetical order. You must use credentials for the instance of the
|
1950
|
+
# service that owns a model to list information about its words.
|
1951
|
+
#
|
1952
|
+
# **See also:** [Listing words from a custom language
|
1953
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/language-words.html#listWords).
|
1954
|
+
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
1955
|
+
# the request. You must make the request with credentials for the instance of the
|
1956
|
+
# service that owns the custom model.
|
1957
|
+
# @param word_type [String] The type of words to be listed from the custom language model's words resource:
|
1958
|
+
# * `all` (the default) shows all words.
|
1959
|
+
# * `user` shows only custom words that were added or modified by the user directly.
|
1960
|
+
# * `corpora` shows only OOV that were extracted from corpora.
|
1961
|
+
# * `grammars` shows only OOV words that are recognized by grammars.
|
1962
|
+
# @param sort [String] Indicates the order in which the words are to be listed, `alphabetical` or by
|
1963
|
+
# `count`. You can prepend an optional `+` or `-` to an argument to indicate whether
|
1964
|
+
# the results are to be sorted in ascending or descending order. By default, words
|
1965
|
+
# are sorted in ascending alphabetical order. For alphabetical ordering, the
|
1966
|
+
# lexicographical precedence is numeric values, uppercase letters, and lowercase
|
1967
|
+
# letters. For count ordering, values with the same count are ordered
|
1968
|
+
# alphabetically. With the `curl` command, URL encode the `+` symbol as `%2B`.
|
1969
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
1970
|
+
def list_words(customization_id:, word_type: nil, sort: nil)
|
1971
|
+
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
1972
|
+
|
1973
|
+
headers = {
|
1974
|
+
}
|
1975
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "list_words")
|
1976
|
+
headers.merge!(sdk_headers)
|
1977
|
+
|
1978
|
+
params = {
|
1979
|
+
"word_type" => word_type,
|
1980
|
+
"sort" => sort
|
1981
|
+
}
|
1982
|
+
|
1983
|
+
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
1994
1984
|
|
1995
1985
|
response = request(
|
1996
1986
|
method: "GET",
|
1997
1987
|
url: method_url,
|
1998
1988
|
headers: headers,
|
1989
|
+
params: params,
|
1999
1990
|
accept_json: true
|
2000
1991
|
)
|
2001
1992
|
response
|
2002
1993
|
end
|
1994
|
+
#########################
|
1995
|
+
# Custom grammars
|
1996
|
+
#########################
|
2003
1997
|
|
2004
1998
|
##
|
2005
1999
|
# @!method add_grammar(customization_id:, grammar_name:, grammar_file:, content_type:, allow_overwrite: nil)
|
@@ -2082,7 +2076,8 @@ module IBMWatson
|
|
2082
2076
|
headers = {
|
2083
2077
|
"Content-Type" => content_type
|
2084
2078
|
}
|
2085
|
-
|
2079
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "add_grammar")
|
2080
|
+
headers.merge!(sdk_headers)
|
2086
2081
|
|
2087
2082
|
params = {
|
2088
2083
|
"allow_overwrite" => allow_overwrite
|
@@ -2103,6 +2098,45 @@ module IBMWatson
|
|
2103
2098
|
nil
|
2104
2099
|
end
|
2105
2100
|
|
2101
|
+
##
|
2102
|
+
# @!method delete_grammar(customization_id:, grammar_name:)
|
2103
|
+
# Delete a grammar.
|
2104
|
+
# Deletes an existing grammar from a custom language model. The service removes any
|
2105
|
+
# out-of-vocabulary (OOV) words associated with the grammar from the custom model's
|
2106
|
+
# words resource unless they were also added by another resource or they were
|
2107
|
+
# modified in some way with the **Add custom words** or **Add a custom word**
|
2108
|
+
# method. Removing a grammar does not affect the custom model until you train the
|
2109
|
+
# model with the **Train a custom language model** method. You must use credentials
|
2110
|
+
# for the instance of the service that owns a model to delete its grammar.
|
2111
|
+
#
|
2112
|
+
# **See also:** [Deleting a grammar from a custom language
|
2113
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/).
|
2114
|
+
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
2115
|
+
# the request. You must make the request with credentials for the instance of the
|
2116
|
+
# service that owns the custom model.
|
2117
|
+
# @param grammar_name [String] The name of the grammar for the custom language model.
|
2118
|
+
# @return [nil]
|
2119
|
+
def delete_grammar(customization_id:, grammar_name:)
|
2120
|
+
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2121
|
+
|
2122
|
+
raise ArgumentError.new("grammar_name must be provided") if grammar_name.nil?
|
2123
|
+
|
2124
|
+
headers = {
|
2125
|
+
}
|
2126
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "delete_grammar")
|
2127
|
+
headers.merge!(sdk_headers)
|
2128
|
+
|
2129
|
+
method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]
|
2130
|
+
|
2131
|
+
request(
|
2132
|
+
method: "DELETE",
|
2133
|
+
url: method_url,
|
2134
|
+
headers: headers,
|
2135
|
+
accept_json: true
|
2136
|
+
)
|
2137
|
+
nil
|
2138
|
+
end
|
2139
|
+
|
2106
2140
|
##
|
2107
2141
|
# @!method get_grammar(customization_id:, grammar_name:)
|
2108
2142
|
# Get a grammar.
|
@@ -2125,7 +2159,8 @@ module IBMWatson
|
|
2125
2159
|
|
2126
2160
|
headers = {
|
2127
2161
|
}
|
2128
|
-
|
2162
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "get_grammar")
|
2163
|
+
headers.merge!(sdk_headers)
|
2129
2164
|
|
2130
2165
|
method_url = "/v1/customizations/%s/grammars/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(grammar_name)]
|
2131
2166
|
|
@@ -2139,41 +2174,36 @@ module IBMWatson
|
|
2139
2174
|
end
|
2140
2175
|
|
2141
2176
|
##
|
2142
|
-
# @!method
|
2143
|
-
#
|
2144
|
-
#
|
2145
|
-
# out-of-vocabulary (OOV) words
|
2146
|
-
#
|
2147
|
-
#
|
2148
|
-
# method. Removing a grammar does not affect the custom model until you train the
|
2149
|
-
# model with the **Train a custom language model** method. You must use credentials
|
2150
|
-
# for the instance of the service that owns a model to delete its grammar.
|
2177
|
+
# @!method list_grammars(customization_id:)
|
2178
|
+
# List grammars.
|
2179
|
+
# Lists information about all grammars from a custom language model. The information
|
2180
|
+
# includes the total number of out-of-vocabulary (OOV) words, name, and status of
|
2181
|
+
# each grammar. You must use credentials for the instance of the service that owns a
|
2182
|
+
# model to list its grammars.
|
2151
2183
|
#
|
2152
|
-
# **See also:** [
|
2184
|
+
# **See also:** [Listing grammars from a custom language
|
2153
2185
|
# model](https://cloud.ibm.com/docs/services/speech-to-text/).
|
2154
2186
|
# @param customization_id [String] The customization ID (GUID) of the custom language model that is to be used for
|
2155
2187
|
# the request. You must make the request with credentials for the instance of the
|
2156
2188
|
# service that owns the custom model.
|
2157
|
-
# @
|
2158
|
-
|
2159
|
-
|
2160
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2161
|
-
|
2162
|
-
raise ArgumentError.new("grammar_name must be provided") if grammar_name.nil?
|
2189
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
2190
|
+
def list_grammars(customization_id:)
|
2191
|
+
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2163
2192
|
|
2164
2193
|
headers = {
|
2165
2194
|
}
|
2166
|
-
|
2195
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "list_grammars")
|
2196
|
+
headers.merge!(sdk_headers)
|
2167
2197
|
|
2168
|
-
method_url = "/v1/customizations/%s/grammars
|
2198
|
+
method_url = "/v1/customizations/%s/grammars" % [ERB::Util.url_encode(customization_id)]
|
2169
2199
|
|
2170
|
-
request(
|
2171
|
-
method: "
|
2200
|
+
response = request(
|
2201
|
+
method: "GET",
|
2172
2202
|
url: method_url,
|
2173
2203
|
headers: headers,
|
2174
2204
|
accept_json: true
|
2175
2205
|
)
|
2176
|
-
|
2206
|
+
response
|
2177
2207
|
end
|
2178
2208
|
#########################
|
2179
2209
|
# Custom acoustic models
|
@@ -2188,7 +2218,7 @@ module IBMWatson
|
|
2188
2218
|
# it.
|
2189
2219
|
#
|
2190
2220
|
# **See also:** [Create a custom acoustic
|
2191
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-create.html#createModel).
|
2221
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-create.html#createModel-acoustic).
|
2192
2222
|
# @param name [String] A user-defined name for the new custom acoustic model. Use a name that is unique
|
2193
2223
|
# among all custom acoustic models that you own. Use a localized name that matches
|
2194
2224
|
# the language of the custom model. Use a name that describes the acoustic
|
@@ -2211,7 +2241,8 @@ module IBMWatson
|
|
2211
2241
|
|
2212
2242
|
headers = {
|
2213
2243
|
}
|
2214
|
-
|
2244
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "create_acoustic_model")
|
2245
|
+
headers.merge!(sdk_headers)
|
2215
2246
|
|
2216
2247
|
data = {
|
2217
2248
|
"name" => name,
|
@@ -2232,39 +2263,36 @@ module IBMWatson
|
|
2232
2263
|
end
|
2233
2264
|
|
2234
2265
|
##
|
2235
|
-
# @!method
|
2236
|
-
#
|
2237
|
-
#
|
2238
|
-
#
|
2239
|
-
#
|
2240
|
-
#
|
2241
|
-
# a model to list information about it.
|
2266
|
+
# @!method delete_acoustic_model(customization_id:)
|
2267
|
+
# Delete a custom acoustic model.
|
2268
|
+
# Deletes an existing custom acoustic model. The custom model cannot be deleted if
|
2269
|
+
# another request, such as adding an audio resource to the model, is currently being
|
2270
|
+
# processed. You must use credentials for the instance of the service that owns a
|
2271
|
+
# model to delete it.
|
2242
2272
|
#
|
2243
|
-
# **See also:** [
|
2244
|
-
#
|
2245
|
-
# @param
|
2246
|
-
#
|
2247
|
-
#
|
2248
|
-
# @return [
|
2249
|
-
def
|
2250
|
-
|
2251
|
-
}
|
2252
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "list_acoustic_models")
|
2273
|
+
# **See also:** [Deleting a custom acoustic
|
2274
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-models.html#deleteModel-acoustic).
|
2275
|
+
# @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
|
2276
|
+
# the request. You must make the request with credentials for the instance of the
|
2277
|
+
# service that owns the custom model.
|
2278
|
+
# @return [nil]
|
2279
|
+
def delete_acoustic_model(customization_id:)
|
2280
|
+
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2253
2281
|
|
2254
|
-
|
2255
|
-
"language" => language
|
2282
|
+
headers = {
|
2256
2283
|
}
|
2284
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "delete_acoustic_model")
|
2285
|
+
headers.merge!(sdk_headers)
|
2257
2286
|
|
2258
|
-
method_url = "/v1/acoustic_customizations"
|
2287
|
+
method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
2259
2288
|
|
2260
|
-
|
2261
|
-
method: "
|
2289
|
+
request(
|
2290
|
+
method: "DELETE",
|
2262
2291
|
url: method_url,
|
2263
2292
|
headers: headers,
|
2264
|
-
params: params,
|
2265
2293
|
accept_json: true
|
2266
2294
|
)
|
2267
|
-
|
2295
|
+
nil
|
2268
2296
|
end
|
2269
2297
|
|
2270
2298
|
##
|
@@ -2274,7 +2302,7 @@ module IBMWatson
|
|
2274
2302
|
# for the instance of the service that owns a model to list information about it.
|
2275
2303
|
#
|
2276
2304
|
# **See also:** [Listing custom acoustic
|
2277
|
-
# models](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-models.html#listModels).
|
2305
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-models.html#listModels-acoustic).
|
2278
2306
|
# @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
|
2279
2307
|
# the request. You must make the request with credentials for the instance of the
|
2280
2308
|
# service that owns the custom model.
|
@@ -2284,7 +2312,8 @@ module IBMWatson
|
|
2284
2312
|
|
2285
2313
|
headers = {
|
2286
2314
|
}
|
2287
|
-
|
2315
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "get_acoustic_model")
|
2316
|
+
headers.merge!(sdk_headers)
|
2288
2317
|
|
2289
2318
|
method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
2290
2319
|
|
@@ -2298,30 +2327,69 @@ module IBMWatson
|
|
2298
2327
|
end
|
2299
2328
|
|
2300
2329
|
##
|
2301
|
-
# @!method
|
2302
|
-
#
|
2303
|
-
#
|
2304
|
-
#
|
2305
|
-
#
|
2306
|
-
#
|
2330
|
+
# @!method list_acoustic_models(language: nil)
|
2331
|
+
# List custom acoustic models.
|
2332
|
+
# Lists information about all custom acoustic models that are owned by an instance
|
2333
|
+
# of the service. Use the `language` parameter to see all custom acoustic models for
|
2334
|
+
# the specified language. Omit the parameter to see all custom acoustic models for
|
2335
|
+
# all languages. You must use credentials for the instance of the service that owns
|
2336
|
+
# a model to list information about it.
|
2307
2337
|
#
|
2308
|
-
# **See also:** [
|
2309
|
-
#
|
2338
|
+
# **See also:** [Listing custom acoustic
|
2339
|
+
# models](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-models.html#listModels-acoustic).
|
2340
|
+
# @param language [String] The identifier of the language for which custom language or custom acoustic models
|
2341
|
+
# are to be returned (for example, `en-US`). Omit the parameter to see all custom
|
2342
|
+
# language or custom acoustic models that are owned by the requesting credentials.
|
2343
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
2344
|
+
def list_acoustic_models(language: nil)
|
2345
|
+
headers = {
|
2346
|
+
}
|
2347
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "list_acoustic_models")
|
2348
|
+
headers.merge!(sdk_headers)
|
2349
|
+
|
2350
|
+
params = {
|
2351
|
+
"language" => language
|
2352
|
+
}
|
2353
|
+
|
2354
|
+
method_url = "/v1/acoustic_customizations"
|
2355
|
+
|
2356
|
+
response = request(
|
2357
|
+
method: "GET",
|
2358
|
+
url: method_url,
|
2359
|
+
headers: headers,
|
2360
|
+
params: params,
|
2361
|
+
accept_json: true
|
2362
|
+
)
|
2363
|
+
response
|
2364
|
+
end
|
2365
|
+
|
2366
|
+
##
|
2367
|
+
# @!method reset_acoustic_model(customization_id:)
|
2368
|
+
# Reset a custom acoustic model.
|
2369
|
+
# Resets a custom acoustic model by removing all audio resources from the model.
|
2370
|
+
# Resetting a custom acoustic model initializes the model to its state when it was
|
2371
|
+
# first created. Metadata such as the name and language of the model are preserved,
|
2372
|
+
# but the model's audio resources are removed and must be re-created. You must use
|
2373
|
+
# credentials for the instance of the service that owns a model to reset it.
|
2374
|
+
#
|
2375
|
+
# **See also:** [Resetting a custom acoustic
|
2376
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-models.html#resetModel-acoustic).
|
2310
2377
|
# @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
|
2311
2378
|
# the request. You must make the request with credentials for the instance of the
|
2312
2379
|
# service that owns the custom model.
|
2313
2380
|
# @return [nil]
|
2314
|
-
def
|
2381
|
+
def reset_acoustic_model(customization_id:)
|
2315
2382
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2316
2383
|
|
2317
2384
|
headers = {
|
2318
2385
|
}
|
2319
|
-
|
2386
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "reset_acoustic_model")
|
2387
|
+
headers.merge!(sdk_headers)
|
2320
2388
|
|
2321
|
-
method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
2389
|
+
method_url = "/v1/acoustic_customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
|
2322
2390
|
|
2323
2391
|
request(
|
2324
|
-
method: "
|
2392
|
+
method: "POST",
|
2325
2393
|
url: method_url,
|
2326
2394
|
headers: headers,
|
2327
2395
|
accept_json: true
|
@@ -2357,10 +2425,11 @@ module IBMWatson
|
|
2357
2425
|
#
|
2358
2426
|
# You can use the optional `custom_language_model_id` parameter to specify the GUID
|
2359
2427
|
# of a separately created custom language model that is to be used during training.
|
2360
|
-
#
|
2361
|
-
# files that you have added to the custom model or you have either corpora
|
2362
|
-
# files) or a list of words that are relevant to the contents of the audio
|
2363
|
-
#
|
2428
|
+
# Train with a custom language model if you have verbatim transcriptions of the
|
2429
|
+
# audio files that you have added to the custom model or you have either corpora
|
2430
|
+
# (text files) or a list of words that are relevant to the contents of the audio
|
2431
|
+
# files. Both of the custom models must be based on the same version of the same
|
2432
|
+
# base model for training to succeed.
|
2364
2433
|
#
|
2365
2434
|
# Training can fail to start for the following reasons:
|
2366
2435
|
# * The service is currently handling another request for the custom model, such as
|
@@ -2373,7 +2442,7 @@ module IBMWatson
|
|
2373
2442
|
# the same version of the same base model.
|
2374
2443
|
#
|
2375
2444
|
# **See also:** [Train the custom acoustic
|
2376
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-create.html#trainModel).
|
2445
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-create.html#trainModel-acoustic).
|
2377
2446
|
# @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
|
2378
2447
|
# the request. You must make the request with credentials for the instance of the
|
2379
2448
|
# service that owns the custom model.
|
@@ -2390,7 +2459,8 @@ module IBMWatson
|
|
2390
2459
|
|
2391
2460
|
headers = {
|
2392
2461
|
}
|
2393
|
-
|
2462
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "train_acoustic_model")
|
2463
|
+
headers.merge!(sdk_headers)
|
2394
2464
|
|
2395
2465
|
params = {
|
2396
2466
|
"custom_language_model_id" => custom_language_model_id
|
@@ -2408,39 +2478,6 @@ module IBMWatson
|
|
2408
2478
|
nil
|
2409
2479
|
end
|
2410
2480
|
|
2411
|
-
##
|
2412
|
-
# @!method reset_acoustic_model(customization_id:)
|
2413
|
-
# Reset a custom acoustic model.
|
2414
|
-
# Resets a custom acoustic model by removing all audio resources from the model.
|
2415
|
-
# Resetting a custom acoustic model initializes the model to its state when it was
|
2416
|
-
# first created. Metadata such as the name and language of the model are preserved,
|
2417
|
-
# but the model's audio resources are removed and must be re-created. You must use
|
2418
|
-
# credentials for the instance of the service that owns a model to reset it.
|
2419
|
-
#
|
2420
|
-
# **See also:** [Resetting a custom acoustic
|
2421
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-models.html#resetModel).
|
2422
|
-
# @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
|
2423
|
-
# the request. You must make the request with credentials for the instance of the
|
2424
|
-
# service that owns the custom model.
|
2425
|
-
# @return [nil]
|
2426
|
-
def reset_acoustic_model(customization_id:)
|
2427
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2428
|
-
|
2429
|
-
headers = {
|
2430
|
-
}
|
2431
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "reset_acoustic_model")
|
2432
|
-
|
2433
|
-
method_url = "/v1/acoustic_customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
|
2434
|
-
|
2435
|
-
request(
|
2436
|
-
method: "POST",
|
2437
|
-
url: method_url,
|
2438
|
-
headers: headers,
|
2439
|
-
accept_json: true
|
2440
|
-
)
|
2441
|
-
nil
|
2442
|
-
end
|
2443
|
-
|
2444
2481
|
##
|
2445
2482
|
# @!method upgrade_acoustic_model(customization_id:, custom_language_model_id: nil, force: nil)
|
2446
2483
|
# Upgrade a custom acoustic model.
|
@@ -2488,7 +2525,8 @@ module IBMWatson
|
|
2488
2525
|
|
2489
2526
|
headers = {
|
2490
2527
|
}
|
2491
|
-
|
2528
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "upgrade_acoustic_model")
|
2529
|
+
headers.merge!(sdk_headers)
|
2492
2530
|
|
2493
2531
|
params = {
|
2494
2532
|
"custom_language_model_id" => custom_language_model_id,
|
@@ -2511,41 +2549,7 @@ module IBMWatson
|
|
2511
2549
|
#########################
|
2512
2550
|
|
2513
2551
|
##
|
2514
|
-
# @!method
|
2515
|
-
# List audio resources.
|
2516
|
-
# Lists information about all audio resources from a custom acoustic model. The
|
2517
|
-
# information includes the name of the resource and information about its audio
|
2518
|
-
# data, such as its duration. It also includes the status of the audio resource,
|
2519
|
-
# which is important for checking the service's analysis of the resource in response
|
2520
|
-
# to a request to add it to the custom acoustic model. You must use credentials for
|
2521
|
-
# the instance of the service that owns a model to list its audio resources.
|
2522
|
-
#
|
2523
|
-
# **See also:** [Listing audio resources for a custom acoustic
|
2524
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-audio.html#listAudio).
|
2525
|
-
# @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
|
2526
|
-
# the request. You must make the request with credentials for the instance of the
|
2527
|
-
# service that owns the custom model.
|
2528
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
2529
|
-
def list_audio(customization_id:)
|
2530
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2531
|
-
|
2532
|
-
headers = {
|
2533
|
-
}
|
2534
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "speech_to_text", service_version: "V1", operation_id: "list_audio")
|
2535
|
-
|
2536
|
-
method_url = "/v1/acoustic_customizations/%s/audio" % [ERB::Util.url_encode(customization_id)]
|
2537
|
-
|
2538
|
-
response = request(
|
2539
|
-
method: "GET",
|
2540
|
-
url: method_url,
|
2541
|
-
headers: headers,
|
2542
|
-
accept_json: true
|
2543
|
-
)
|
2544
|
-
response
|
2545
|
-
end
|
2546
|
-
|
2547
|
-
##
|
2548
|
-
# @!method add_audio(customization_id:, audio_name:, audio_resource:, content_type: nil, contained_content_type: nil, allow_overwrite: nil)
|
2552
|
+
# @!method add_audio(customization_id:, audio_name:, audio_resource:, contained_content_type: nil, allow_overwrite: nil, content_type: nil)
|
2549
2553
|
# Add an audio resource.
|
2550
2554
|
# Adds an audio resource to a custom acoustic model. Add audio content that reflects
|
2551
2555
|
# the acoustic characteristics of the audio that you plan to transcribe. You must
|
@@ -2593,6 +2597,7 @@ module IBMWatson
|
|
2593
2597
|
# speech recognition. For an audio-type resource, use the `Content-Type` parameter
|
2594
2598
|
# to specify the audio format (MIME type) of the audio file, including specifying
|
2595
2599
|
# the sampling rate, channels, and endianness where indicated.
|
2600
|
+
# * `audio/alaw` (Specify the sampling rate (`rate`) of the audio.)
|
2596
2601
|
# * `audio/basic` (Use only with narrowband models.)
|
2597
2602
|
# * `audio/flac`
|
2598
2603
|
# * `audio/g729` (Use only with narrowband models.)
|
@@ -2628,12 +2633,20 @@ module IBMWatson
|
|
2628
2633
|
# * `application/zip` for a **.zip** file
|
2629
2634
|
# * `application/gzip` for a **.tar.gz** file.
|
2630
2635
|
#
|
2631
|
-
#
|
2632
|
-
#
|
2633
|
-
#
|
2634
|
-
#
|
2635
|
-
#
|
2636
|
-
#
|
2636
|
+
# When you add an archive-type resource, the `Contained-Content-Type` header is
|
2637
|
+
# optional depending on the format of the files that you are adding:
|
2638
|
+
# * For audio files of type `audio/alaw`, `audio/basic`, `audio/l16`, or
|
2639
|
+
# `audio/mulaw`, you must use the `Contained-Content-Type` header to specify the
|
2640
|
+
# format of the contained audio files. Include the `rate`, `channels`, and
|
2641
|
+
# `endianness` parameters where necessary. In this case, all audio files contained
|
2642
|
+
# in the archive file must have the same audio format.
|
2643
|
+
# * For audio files of all other types, you can omit the `Contained-Content-Type`
|
2644
|
+
# header. In this case, the audio files contained in the archive file can have any
|
2645
|
+
# of the formats not listed in the previous bullet. The audio files do not need to
|
2646
|
+
# have the same format.
|
2647
|
+
#
|
2648
|
+
# Do not use the `Contained-Content-Type` header when adding an audio-type resource.
|
2649
|
+
#
|
2637
2650
|
#
|
2638
2651
|
# ### Naming restrictions for embedded audio files
|
2639
2652
|
#
|
@@ -2656,6 +2669,25 @@ module IBMWatson
|
|
2656
2669
|
# custom model.
|
2657
2670
|
# @param audio_resource [String] The audio resource that is to be added to the custom acoustic model, an individual
|
2658
2671
|
# audio file or an archive file.
|
2672
|
+
# @param contained_content_type [String] **For an archive-type resource,** specify the format of the audio files that are
|
2673
|
+
# contained in the archive file if they are of type `audio/alaw`, `audio/basic`,
|
2674
|
+
# `audio/l16`, or `audio/mulaw`. Include the `rate`, `channels`, and `endianness`
|
2675
|
+
# parameters where necessary. In this case, all audio files that are contained in
|
2676
|
+
# the archive file must be of the indicated type.
|
2677
|
+
#
|
2678
|
+
# For all other audio formats, you can omit the header. In this case, the audio
|
2679
|
+
# files can be of multiple types as long as they are not of the types listed in the
|
2680
|
+
# previous paragraph.
|
2681
|
+
#
|
2682
|
+
# The parameter accepts all of the audio formats that are supported for use with
|
2683
|
+
# speech recognition. For more information, see **Content types for audio-type
|
2684
|
+
# resources** in the method description.
|
2685
|
+
#
|
2686
|
+
# **For an audio-type resource,** omit the header.
|
2687
|
+
# @param allow_overwrite [Boolean] If `true`, the specified audio resource overwrites an existing audio resource with
|
2688
|
+
# the same name. If `false`, the request fails if an audio resource with the same
|
2689
|
+
# name already exists. The parameter has no effect if an audio resource with the
|
2690
|
+
# same name does not already exist.
|
2659
2691
|
# @param content_type [String] For an audio-type resource, the format (MIME type) of the audio. For more
|
2660
2692
|
# information, see **Content types for audio-type resources** in the method
|
2661
2693
|
# description.
|
@@ -2663,17 +2695,8 @@ module IBMWatson
|
|
2663
2695
|
# For an archive-type resource, the media type of the archive file. For more
|
2664
2696
|
# information, see **Content types for archive-type resources** in the method
|
2665
2697
|
# description.
|
2666
|
-
# @param contained_content_type [String] For an archive-type resource, specifies the format of the audio files that are
|
2667
|
-
# contained in the archive file. The parameter accepts all of the audio formats that
|
2668
|
-
# are supported for use with speech recognition, including the `rate`, `channels`,
|
2669
|
-
# and `endianness` parameters that are used with some formats. For more information,
|
2670
|
-
# see **Content types for audio-type resources** in the method description.
|
2671
|
-
# @param allow_overwrite [Boolean] If `true`, the specified audio resource overwrites an existing audio resource with
|
2672
|
-
# the same name. If `false`, the request fails if an audio resource with the same
|
2673
|
-
# name already exists. The parameter has no effect if an audio resource with the
|
2674
|
-
# same name does not already exist.
|
2675
2698
|
# @return [nil]
|
2676
|
-
def add_audio(customization_id:, audio_name:, audio_resource:,
|
2699
|
+
def add_audio(customization_id:, audio_name:, audio_resource:, contained_content_type: nil, allow_overwrite: nil, content_type: nil)
|
2677
2700
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2678
2701
|
|
2679
2702
|
raise ArgumentError.new("audio_name must be provided") if audio_name.nil?
|
@@ -2681,10 +2704,11 @@ module IBMWatson
|
|
2681
2704
|
raise ArgumentError.new("audio_resource must be provided") if audio_resource.nil?
|
2682
2705
|
|
2683
2706
|
headers = {
|
2684
|
-
"Content-Type" =>
|
2685
|
-
"
|
2707
|
+
"Contained-Content-Type" => contained_content_type,
|
2708
|
+
"Content-Type" => content_type
|
2686
2709
|
}
|
2687
|
-
|
2710
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "add_audio")
|
2711
|
+
headers.merge!(sdk_headers)
|
2688
2712
|
|
2689
2713
|
params = {
|
2690
2714
|
"allow_overwrite" => allow_overwrite
|
@@ -2705,6 +2729,45 @@ module IBMWatson
|
|
2705
2729
|
nil
|
2706
2730
|
end
|
2707
2731
|
|
2732
|
+
##
|
2733
|
+
# @!method delete_audio(customization_id:, audio_name:)
|
2734
|
+
# Delete an audio resource.
|
2735
|
+
# Deletes an existing audio resource from a custom acoustic model. Deleting an
|
2736
|
+
# archive-type audio resource removes the entire archive of files; the current
|
2737
|
+
# interface does not allow deletion of individual files from an archive resource.
|
2738
|
+
# Removing an audio resource does not affect the custom model until you train the
|
2739
|
+
# model on its updated data by using the **Train a custom acoustic model** method.
|
2740
|
+
# You must use credentials for the instance of the service that owns a model to
|
2741
|
+
# delete its audio resources.
|
2742
|
+
#
|
2743
|
+
# **See also:** [Deleting an audio resource from a custom acoustic
|
2744
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-audio.html#deleteAudio).
|
2745
|
+
# @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
|
2746
|
+
# the request. You must make the request with credentials for the instance of the
|
2747
|
+
# service that owns the custom model.
|
2748
|
+
# @param audio_name [String] The name of the audio resource for the custom acoustic model.
|
2749
|
+
# @return [nil]
|
2750
|
+
def delete_audio(customization_id:, audio_name:)
|
2751
|
+
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2752
|
+
|
2753
|
+
raise ArgumentError.new("audio_name must be provided") if audio_name.nil?
|
2754
|
+
|
2755
|
+
headers = {
|
2756
|
+
}
|
2757
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "delete_audio")
|
2758
|
+
headers.merge!(sdk_headers)
|
2759
|
+
|
2760
|
+
method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
|
2761
|
+
|
2762
|
+
request(
|
2763
|
+
method: "DELETE",
|
2764
|
+
url: method_url,
|
2765
|
+
headers: headers,
|
2766
|
+
accept_json: true
|
2767
|
+
)
|
2768
|
+
nil
|
2769
|
+
end
|
2770
|
+
|
2708
2771
|
##
|
2709
2772
|
# @!method get_audio(customization_id:, audio_name:)
|
2710
2773
|
# Get an audio resource.
|
@@ -2743,7 +2806,8 @@ module IBMWatson
|
|
2743
2806
|
|
2744
2807
|
headers = {
|
2745
2808
|
}
|
2746
|
-
|
2809
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "get_audio")
|
2810
|
+
headers.merge!(sdk_headers)
|
2747
2811
|
|
2748
2812
|
method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
|
2749
2813
|
|
@@ -2757,41 +2821,38 @@ module IBMWatson
|
|
2757
2821
|
end
|
2758
2822
|
|
2759
2823
|
##
|
2760
|
-
# @!method
|
2761
|
-
#
|
2762
|
-
#
|
2763
|
-
#
|
2764
|
-
#
|
2765
|
-
#
|
2766
|
-
#
|
2767
|
-
#
|
2768
|
-
# delete its audio resources.
|
2824
|
+
# @!method list_audio(customization_id:)
|
2825
|
+
# List audio resources.
|
2826
|
+
# Lists information about all audio resources from a custom acoustic model. The
|
2827
|
+
# information includes the name of the resource and information about its audio
|
2828
|
+
# data, such as its duration. It also includes the status of the audio resource,
|
2829
|
+
# which is important for checking the service's analysis of the resource in response
|
2830
|
+
# to a request to add it to the custom acoustic model. You must use credentials for
|
2831
|
+
# the instance of the service that owns a model to list its audio resources.
|
2769
2832
|
#
|
2770
|
-
# **See also:** [
|
2771
|
-
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-audio.html#
|
2833
|
+
# **See also:** [Listing audio resources for a custom acoustic
|
2834
|
+
# model](https://cloud.ibm.com/docs/services/speech-to-text/acoustic-audio.html#listAudio).
|
2772
2835
|
# @param customization_id [String] The customization ID (GUID) of the custom acoustic model that is to be used for
|
2773
2836
|
# the request. You must make the request with credentials for the instance of the
|
2774
2837
|
# service that owns the custom model.
|
2775
|
-
# @
|
2776
|
-
|
2777
|
-
def delete_audio(customization_id:, audio_name:)
|
2838
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
2839
|
+
def list_audio(customization_id:)
|
2778
2840
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
2779
2841
|
|
2780
|
-
raise ArgumentError.new("audio_name must be provided") if audio_name.nil?
|
2781
|
-
|
2782
2842
|
headers = {
|
2783
2843
|
}
|
2784
|
-
|
2844
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "list_audio")
|
2845
|
+
headers.merge!(sdk_headers)
|
2785
2846
|
|
2786
|
-
method_url = "/v1/acoustic_customizations/%s/audio
|
2847
|
+
method_url = "/v1/acoustic_customizations/%s/audio" % [ERB::Util.url_encode(customization_id)]
|
2787
2848
|
|
2788
|
-
request(
|
2789
|
-
method: "
|
2849
|
+
response = request(
|
2850
|
+
method: "GET",
|
2790
2851
|
url: method_url,
|
2791
2852
|
headers: headers,
|
2792
2853
|
accept_json: true
|
2793
2854
|
)
|
2794
|
-
|
2855
|
+
response
|
2795
2856
|
end
|
2796
2857
|
#########################
|
2797
2858
|
# User data
|
@@ -2818,7 +2879,8 @@ module IBMWatson
|
|
2818
2879
|
|
2819
2880
|
headers = {
|
2820
2881
|
}
|
2821
|
-
|
2882
|
+
sdk_headers = Common.new.get_sdk_headers("speech_to_text", "V1", "delete_user_data")
|
2883
|
+
headers.merge!(sdk_headers)
|
2822
2884
|
|
2823
2885
|
params = {
|
2824
2886
|
"customer_id" => customer_id
|
@@ -2831,7 +2893,7 @@ module IBMWatson
|
|
2831
2893
|
url: method_url,
|
2832
2894
|
headers: headers,
|
2833
2895
|
params: params,
|
2834
|
-
accept_json:
|
2896
|
+
accept_json: false
|
2835
2897
|
)
|
2836
2898
|
nil
|
2837
2899
|
end
|