ibm_watson 0.16.1 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -12
- data/lib/ibm_watson/assistant_v1.rb +745 -720
- data/lib/ibm_watson/assistant_v2.rb +23 -19
- data/lib/ibm_watson/compare_comply_v1.rb +94 -89
- data/lib/ibm_watson/discovery_v1.rb +684 -687
- data/lib/ibm_watson/language_translator_v3.rb +234 -33
- data/lib/ibm_watson/natural_language_classifier_v1.rb +33 -29
- data/lib/ibm_watson/natural_language_understanding_v1.rb +33 -29
- data/lib/ibm_watson/personality_insights_v3.rb +18 -14
- data/lib/ibm_watson/speech_to_text_v1.rb +799 -725
- data/lib/ibm_watson/text_to_speech_v1.rb +201 -196
- data/lib/ibm_watson/tone_analyzer_v3.rb +15 -11
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +52 -48
- data/test/integration/test_language_translator_v3.rb +37 -1
- data/test/unit/test_language_translator_v3.rb +201 -16
- data/test/unit/test_speech_to_text_v1.rb +2 -2
- metadata +5 -5
@@ -14,7 +14,6 @@
|
|
14
14
|
# See the License for the specific language governing permissions and
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
|
-
# ### Service Overview
|
18
17
|
# The IBM® Text to Speech service provides APIs that use IBM's speech-synthesis
|
19
18
|
# capabilities to synthesize text into natural-sounding speech in a variety of languages,
|
20
19
|
# dialects, and voices. The service supports at least one male or female voice, sometimes
|
@@ -52,16 +51,16 @@ module IBMWatson
|
|
52
51
|
# @param args [Hash] The args to initialize with
|
53
52
|
# @option args url [String] The base url to use when contacting the service (e.g.
|
54
53
|
# "https://stream.watsonplatform.net/text-to-speech/api").
|
55
|
-
# The base url may differ between
|
54
|
+
# The base url may differ between IBM Cloud regions.
|
56
55
|
# @option args username [String] The username used to authenticate with the service.
|
57
56
|
# Username and password credentials are only required to run your
|
58
|
-
# application locally or outside of
|
59
|
-
#
|
57
|
+
# application locally or outside of IBM Cloud. When running on
|
58
|
+
# IBM Cloud, the credentials will be automatically loaded from the
|
60
59
|
# `VCAP_SERVICES` environment variable.
|
61
60
|
# @option args password [String] The password used to authenticate with the service.
|
62
61
|
# Username and password credentials are only required to run your
|
63
|
-
# application locally or outside of
|
64
|
-
#
|
62
|
+
# application locally or outside of IBM Cloud. When running on
|
63
|
+
# IBM Cloud, the credentials will be automatically loaded from the
|
65
64
|
# `VCAP_SERVICES` environment variable.
|
66
65
|
# @option args iam_apikey [String] An API key that can be used to request IAM tokens. If
|
67
66
|
# this API key is provided, the SDK will manage the token and handle the
|
@@ -71,7 +70,9 @@ module IBMWatson
|
|
71
70
|
# it expires or reactively upon receiving a 401 from the service as any requests
|
72
71
|
# made with an expired token will fail.
|
73
72
|
# @option args iam_url [String] An optional URL for the IAM service API. Defaults to
|
74
|
-
# 'https://iam.
|
73
|
+
# 'https://iam.cloud.ibm.com/identity/token'.
|
74
|
+
# @option args iam_client_id [String] An optional client id for the IAM service API.
|
75
|
+
# @option args iam_client_secret [String] An optional client secret for the IAM service API.
|
75
76
|
def initialize(args = {})
|
76
77
|
@__async_initialized__ = false
|
77
78
|
defaults = {}
|
@@ -81,6 +82,8 @@ module IBMWatson
|
|
81
82
|
defaults[:iam_apikey] = nil
|
82
83
|
defaults[:iam_access_token] = nil
|
83
84
|
defaults[:iam_url] = nil
|
85
|
+
defaults[:iam_client_id] = nil
|
86
|
+
defaults[:iam_client_secret] = nil
|
84
87
|
args = defaults.merge(args)
|
85
88
|
args[:vcap_services_name] = "text_to_speech"
|
86
89
|
super
|
@@ -91,6 +94,33 @@ module IBMWatson
|
|
91
94
|
# Voices
|
92
95
|
#########################
|
93
96
|
|
97
|
+
##
|
98
|
+
# @!method list_voices
|
99
|
+
# List voices.
|
100
|
+
# Lists all voices available for use with the service. The information includes the
|
101
|
+
# name, language, gender, and other details about the voice. To see information
|
102
|
+
# about a specific voice, use the **Get a voice** method.
|
103
|
+
#
|
104
|
+
# **See also:** [Listing all available
|
105
|
+
# voices](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-voices#listVoices).
|
106
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
107
|
+
def list_voices
|
108
|
+
headers = {
|
109
|
+
}
|
110
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "list_voices")
|
111
|
+
headers.merge!(sdk_headers)
|
112
|
+
|
113
|
+
method_url = "/v1/voices"
|
114
|
+
|
115
|
+
response = request(
|
116
|
+
method: "GET",
|
117
|
+
url: method_url,
|
118
|
+
headers: headers,
|
119
|
+
accept_json: true
|
120
|
+
)
|
121
|
+
response
|
122
|
+
end
|
123
|
+
|
94
124
|
##
|
95
125
|
# @!method get_voice(voice:, customization_id: nil)
|
96
126
|
# Get a voice.
|
@@ -100,7 +130,7 @@ module IBMWatson
|
|
100
130
|
# information about all available voices, use the **List voices** method.
|
101
131
|
#
|
102
132
|
# **See also:** [Listing a specific
|
103
|
-
# voice](https://cloud.ibm.com/docs/services/text-to-speech
|
133
|
+
# voice](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-voices#listVoice).
|
104
134
|
# @param voice [String] The voice for which information is to be returned.
|
105
135
|
# @param customization_id [String] The customization ID (GUID) of a custom voice model for which information is to be
|
106
136
|
# returned. You must make the request with service credentials created for the
|
@@ -130,33 +160,6 @@ module IBMWatson
|
|
130
160
|
)
|
131
161
|
response
|
132
162
|
end
|
133
|
-
|
134
|
-
##
|
135
|
-
# @!method list_voices
|
136
|
-
# List voices.
|
137
|
-
# Lists all voices available for use with the service. The information includes the
|
138
|
-
# name, language, gender, and other details about the voice. To see information
|
139
|
-
# about a specific voice, use the **Get a voice** method.
|
140
|
-
#
|
141
|
-
# **See also:** [Listing all available
|
142
|
-
# voices](https://cloud.ibm.com/docs/services/text-to-speech/voices.html#listVoices).
|
143
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
144
|
-
def list_voices
|
145
|
-
headers = {
|
146
|
-
}
|
147
|
-
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "list_voices")
|
148
|
-
headers.merge!(sdk_headers)
|
149
|
-
|
150
|
-
method_url = "/v1/voices"
|
151
|
-
|
152
|
-
response = request(
|
153
|
-
method: "GET",
|
154
|
-
url: method_url,
|
155
|
-
headers: headers,
|
156
|
-
accept_json: true
|
157
|
-
)
|
158
|
-
response
|
159
|
-
end
|
160
163
|
#########################
|
161
164
|
# Synthesis
|
162
165
|
#########################
|
@@ -173,7 +176,8 @@ module IBMWatson
|
|
173
176
|
# specify. The service returns the synthesized audio stream as an array of bytes.
|
174
177
|
#
|
175
178
|
# **See also:** [The HTTP
|
176
|
-
# interface](https://cloud.ibm.com/docs/services/text-to-speech
|
179
|
+
# interface](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-usingHTTP#usingHTTP).
|
180
|
+
#
|
177
181
|
#
|
178
182
|
# ### Audio formats (accept types)
|
179
183
|
#
|
@@ -241,7 +245,8 @@ module IBMWatson
|
|
241
245
|
#
|
242
246
|
# For more information about specifying an audio format, including additional
|
243
247
|
# details about some of the formats, see [Audio
|
244
|
-
# formats](https://cloud.ibm.com/docs/services/text-to-speech
|
248
|
+
# formats](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-audioFormats#audioFormats).
|
249
|
+
#
|
245
250
|
#
|
246
251
|
# ### Warning messages
|
247
252
|
#
|
@@ -310,7 +315,7 @@ module IBMWatson
|
|
310
315
|
# **Note:** This method is currently a beta release.
|
311
316
|
#
|
312
317
|
# **See also:** [Querying a word from a
|
313
|
-
# language](https://cloud.ibm.com/docs/services/text-to-speech
|
318
|
+
# language](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryLanguage).
|
314
319
|
# @param text [String] The word for which the pronunciation is requested.
|
315
320
|
# @param voice [String] A voice that specifies the language in which the pronunciation is to be returned.
|
316
321
|
# All voices for the same language (for example, `en-US`) return the same
|
@@ -366,7 +371,7 @@ module IBMWatson
|
|
366
371
|
# **Note:** This method is currently a beta release.
|
367
372
|
#
|
368
373
|
# **See also:** [Creating a custom
|
369
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech
|
374
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsCreate).
|
370
375
|
# @param name [String] The name of the new custom voice model.
|
371
376
|
# @param language [String] The language of the new custom voice model. Omit the parameter to use the the
|
372
377
|
# default language, `en-US`.
|
@@ -399,74 +404,6 @@ module IBMWatson
|
|
399
404
|
response
|
400
405
|
end
|
401
406
|
|
402
|
-
##
|
403
|
-
# @!method delete_voice_model(customization_id:)
|
404
|
-
# Delete a custom model.
|
405
|
-
# Deletes the specified custom voice model. You must use credentials for the
|
406
|
-
# instance of the service that owns a model to delete it.
|
407
|
-
#
|
408
|
-
# **Note:** This method is currently a beta release.
|
409
|
-
#
|
410
|
-
# **See also:** [Deleting a custom
|
411
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-models.html#cuModelsDelete).
|
412
|
-
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
413
|
-
# with service credentials created for the instance of the service that owns the
|
414
|
-
# custom model.
|
415
|
-
# @return [nil]
|
416
|
-
def delete_voice_model(customization_id:)
|
417
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
418
|
-
|
419
|
-
headers = {
|
420
|
-
}
|
421
|
-
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "delete_voice_model")
|
422
|
-
headers.merge!(sdk_headers)
|
423
|
-
|
424
|
-
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
425
|
-
|
426
|
-
request(
|
427
|
-
method: "DELETE",
|
428
|
-
url: method_url,
|
429
|
-
headers: headers,
|
430
|
-
accept_json: false
|
431
|
-
)
|
432
|
-
nil
|
433
|
-
end
|
434
|
-
|
435
|
-
##
|
436
|
-
# @!method get_voice_model(customization_id:)
|
437
|
-
# Get a custom model.
|
438
|
-
# Gets all information about a specified custom voice model. In addition to metadata
|
439
|
-
# such as the name and description of the voice model, the output includes the words
|
440
|
-
# and their translations as defined in the model. To see just the metadata for a
|
441
|
-
# voice model, use the **List custom models** method.
|
442
|
-
#
|
443
|
-
# **Note:** This method is currently a beta release.
|
444
|
-
#
|
445
|
-
# **See also:** [Querying a custom
|
446
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-models.html#cuModelsQuery).
|
447
|
-
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
448
|
-
# with service credentials created for the instance of the service that owns the
|
449
|
-
# custom model.
|
450
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
451
|
-
def get_voice_model(customization_id:)
|
452
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
453
|
-
|
454
|
-
headers = {
|
455
|
-
}
|
456
|
-
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "get_voice_model")
|
457
|
-
headers.merge!(sdk_headers)
|
458
|
-
|
459
|
-
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
460
|
-
|
461
|
-
response = request(
|
462
|
-
method: "GET",
|
463
|
-
url: method_url,
|
464
|
-
headers: headers,
|
465
|
-
accept_json: true
|
466
|
-
)
|
467
|
-
response
|
468
|
-
end
|
469
|
-
|
470
407
|
##
|
471
408
|
# @!method list_voice_models(language: nil)
|
472
409
|
# List custom models.
|
@@ -480,7 +417,7 @@ module IBMWatson
|
|
480
417
|
# **Note:** This method is currently a beta release.
|
481
418
|
#
|
482
419
|
# **See also:** [Querying all custom
|
483
|
-
# models](https://cloud.ibm.com/docs/services/text-to-speech
|
420
|
+
# models](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsQueryAll).
|
484
421
|
# @param language [String] The language for which custom voice models that are owned by the requesting
|
485
422
|
# service credentials are to be returned. Omit the parameter to see all custom voice
|
486
423
|
# models that are owned by the requester.
|
@@ -535,11 +472,11 @@ module IBMWatson
|
|
535
472
|
#
|
536
473
|
# **See also:**
|
537
474
|
# * [Updating a custom
|
538
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech
|
475
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsUpdate)
|
539
476
|
# * [Adding words to a Japanese custom
|
540
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech
|
477
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
|
541
478
|
# * [Understanding
|
542
|
-
# customization](https://cloud.ibm.com/docs/services/text-to-speech
|
479
|
+
# customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
|
543
480
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
544
481
|
# with service credentials created for the instance of the service that owns the
|
545
482
|
# custom model.
|
@@ -574,85 +511,77 @@ module IBMWatson
|
|
574
511
|
)
|
575
512
|
nil
|
576
513
|
end
|
577
|
-
#########################
|
578
|
-
# Custom words
|
579
|
-
#########################
|
580
514
|
|
581
515
|
##
|
582
|
-
# @!method
|
583
|
-
#
|
584
|
-
#
|
585
|
-
#
|
586
|
-
#
|
587
|
-
#
|
588
|
-
# model to add a word to it.
|
589
|
-
#
|
590
|
-
# You can define sounds-like or phonetic translations for words. A sounds-like
|
591
|
-
# translation consists of one or more words that, when combined, sound like the
|
592
|
-
# word. Phonetic translations are based on the SSML phoneme format for representing
|
593
|
-
# a word. You can specify them in standard International Phonetic Alphabet (IPA)
|
594
|
-
# representation
|
595
|
-
#
|
596
|
-
# <code><phoneme alphabet=\"ipa\"
|
597
|
-
# ph=\"təmˈɑto\"></phoneme></code>
|
516
|
+
# @!method get_voice_model(customization_id:)
|
517
|
+
# Get a custom model.
|
518
|
+
# Gets all information about a specified custom voice model. In addition to metadata
|
519
|
+
# such as the name and description of the voice model, the output includes the words
|
520
|
+
# and their translations as defined in the model. To see just the metadata for a
|
521
|
+
# voice model, use the **List custom models** method.
|
598
522
|
#
|
599
|
-
#
|
523
|
+
# **Note:** This method is currently a beta release.
|
600
524
|
#
|
601
|
-
#
|
602
|
-
#
|
525
|
+
# **See also:** [Querying a custom
|
526
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsQuery).
|
527
|
+
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
528
|
+
# with service credentials created for the instance of the service that owns the
|
529
|
+
# custom model.
|
530
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
531
|
+
def get_voice_model(customization_id:)
|
532
|
+
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
533
|
+
|
534
|
+
headers = {
|
535
|
+
}
|
536
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "get_voice_model")
|
537
|
+
headers.merge!(sdk_headers)
|
538
|
+
|
539
|
+
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
540
|
+
|
541
|
+
response = request(
|
542
|
+
method: "GET",
|
543
|
+
url: method_url,
|
544
|
+
headers: headers,
|
545
|
+
accept_json: true
|
546
|
+
)
|
547
|
+
response
|
548
|
+
end
|
549
|
+
|
550
|
+
##
|
551
|
+
# @!method delete_voice_model(customization_id:)
|
552
|
+
# Delete a custom model.
|
553
|
+
# Deletes the specified custom voice model. You must use credentials for the
|
554
|
+
# instance of the service that owns a model to delete it.
|
603
555
|
#
|
604
556
|
# **Note:** This method is currently a beta release.
|
605
557
|
#
|
606
|
-
# **See also:**
|
607
|
-
#
|
608
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordAdd)
|
609
|
-
# * [Adding words to a Japanese custom
|
610
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuJapaneseAdd)
|
611
|
-
# * [Understanding
|
612
|
-
# customization](https://cloud.ibm.com/docs/services/text-to-speech/custom-intro.html).
|
558
|
+
# **See also:** [Deleting a custom
|
559
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customModels#cuModelsDelete).
|
613
560
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
614
561
|
# with service credentials created for the instance of the service that owns the
|
615
562
|
# custom model.
|
616
|
-
# @param word [String] The word that is to be added or updated for the custom voice model.
|
617
|
-
# @param translation [String] The phonetic or sounds-like translation for the word. A phonetic translation is
|
618
|
-
# based on the SSML format for representing the phonetic string of a word either as
|
619
|
-
# an IPA translation or as an IBM SPR translation. A sounds-like is one or more
|
620
|
-
# words that, when combined, sound like the word.
|
621
|
-
# @param part_of_speech [String] **Japanese only.** The part of speech for the word. The service uses the value to
|
622
|
-
# produce the correct intonation for the word. You can create only a single entry,
|
623
|
-
# with or without a single part of speech, for any word; you cannot create multiple
|
624
|
-
# entries with different parts of speech for the same word. For more information,
|
625
|
-
# see [Working with Japanese
|
626
|
-
# entries](https://cloud.ibm.com/docs/services/text-to-speech/custom-rules.html#jaNotes).
|
627
563
|
# @return [nil]
|
628
|
-
def
|
564
|
+
def delete_voice_model(customization_id:)
|
629
565
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
630
566
|
|
631
|
-
raise ArgumentError.new("word must be provided") if word.nil?
|
632
|
-
|
633
|
-
raise ArgumentError.new("translation must be provided") if translation.nil?
|
634
|
-
|
635
567
|
headers = {
|
636
568
|
}
|
637
|
-
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "
|
569
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "delete_voice_model")
|
638
570
|
headers.merge!(sdk_headers)
|
639
571
|
|
640
|
-
|
641
|
-
"translation" => translation,
|
642
|
-
"part_of_speech" => part_of_speech
|
643
|
-
}
|
644
|
-
|
645
|
-
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
|
572
|
+
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
646
573
|
|
647
574
|
request(
|
648
|
-
method: "
|
575
|
+
method: "DELETE",
|
649
576
|
url: method_url,
|
650
577
|
headers: headers,
|
651
|
-
json: data,
|
652
578
|
accept_json: false
|
653
579
|
)
|
654
580
|
nil
|
655
581
|
end
|
582
|
+
#########################
|
583
|
+
# Custom words
|
584
|
+
#########################
|
656
585
|
|
657
586
|
##
|
658
587
|
# @!method add_words(customization_id:, words:)
|
@@ -681,11 +610,11 @@ module IBMWatson
|
|
681
610
|
#
|
682
611
|
# **See also:**
|
683
612
|
# * [Adding multiple words to a custom
|
684
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech
|
613
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsAdd)
|
685
614
|
# * [Adding words to a Japanese custom
|
686
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech
|
615
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
|
687
616
|
# * [Understanding
|
688
|
-
# customization](https://cloud.ibm.com/docs/services/text-to-speech
|
617
|
+
# customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
|
689
618
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
690
619
|
# with service credentials created for the instance of the service that owns the
|
691
620
|
# custom model.
|
@@ -725,37 +654,111 @@ module IBMWatson
|
|
725
654
|
end
|
726
655
|
|
727
656
|
##
|
728
|
-
# @!method
|
729
|
-
#
|
730
|
-
#
|
731
|
-
#
|
657
|
+
# @!method list_words(customization_id:)
|
658
|
+
# List custom words.
|
659
|
+
# Lists all of the words and their translations for the specified custom voice
|
660
|
+
# model. The output shows the translations as they are defined in the model. You
|
661
|
+
# must use credentials for the instance of the service that owns a model to list its
|
662
|
+
# words.
|
732
663
|
#
|
664
|
+
# **Note:** This method is currently a beta release.
|
665
|
+
#
|
666
|
+
# **See also:** [Querying all words from a custom
|
667
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordsQueryModel).
|
668
|
+
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
669
|
+
# with service credentials created for the instance of the service that owns the
|
670
|
+
# custom model.
|
671
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
672
|
+
def list_words(customization_id:)
|
673
|
+
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
674
|
+
|
675
|
+
headers = {
|
676
|
+
}
|
677
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "list_words")
|
678
|
+
headers.merge!(sdk_headers)
|
679
|
+
|
680
|
+
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
681
|
+
|
682
|
+
response = request(
|
683
|
+
method: "GET",
|
684
|
+
url: method_url,
|
685
|
+
headers: headers,
|
686
|
+
accept_json: true
|
687
|
+
)
|
688
|
+
response
|
689
|
+
end
|
690
|
+
|
691
|
+
##
|
692
|
+
# @!method add_word(customization_id:, word:, translation:, part_of_speech: nil)
|
693
|
+
# Add a custom word.
|
694
|
+
# Adds a single word and its translation to the specified custom voice model. Adding
|
695
|
+
# a new translation for a word that already exists in a custom model overwrites the
|
696
|
+
# word's existing translation. A custom model can contain no more than 20,000
|
697
|
+
# entries. You must use credentials for the instance of the service that owns a
|
698
|
+
# model to add a word to it.
|
699
|
+
#
|
700
|
+
# You can define sounds-like or phonetic translations for words. A sounds-like
|
701
|
+
# translation consists of one or more words that, when combined, sound like the
|
702
|
+
# word. Phonetic translations are based on the SSML phoneme format for representing
|
703
|
+
# a word. You can specify them in standard International Phonetic Alphabet (IPA)
|
704
|
+
# representation
|
705
|
+
#
|
706
|
+
# <code><phoneme alphabet=\"ipa\"
|
707
|
+
# ph=\"təmˈɑto\"></phoneme></code>
|
708
|
+
#
|
709
|
+
# or in the proprietary IBM Symbolic Phonetic Representation (SPR)
|
710
|
+
#
|
711
|
+
# <code><phoneme alphabet=\"ibm\"
|
712
|
+
# ph=\"1gAstroEntxrYFXs\"></phoneme></code>
|
733
713
|
#
|
734
714
|
# **Note:** This method is currently a beta release.
|
735
715
|
#
|
736
|
-
# **See also:**
|
737
|
-
#
|
716
|
+
# **See also:**
|
717
|
+
# * [Adding a single word to a custom
|
718
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordAdd)
|
719
|
+
# * [Adding words to a Japanese custom
|
720
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuJapaneseAdd)
|
721
|
+
# * [Understanding
|
722
|
+
# customization](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customIntro#customIntro).
|
738
723
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
739
724
|
# with service credentials created for the instance of the service that owns the
|
740
725
|
# custom model.
|
741
|
-
# @param word [String] The word that is to be
|
726
|
+
# @param word [String] The word that is to be added or updated for the custom voice model.
|
727
|
+
# @param translation [String] The phonetic or sounds-like translation for the word. A phonetic translation is
|
728
|
+
# based on the SSML format for representing the phonetic string of a word either as
|
729
|
+
# an IPA translation or as an IBM SPR translation. A sounds-like is one or more
|
730
|
+
# words that, when combined, sound like the word.
|
731
|
+
# @param part_of_speech [String] **Japanese only.** The part of speech for the word. The service uses the value to
|
732
|
+
# produce the correct intonation for the word. You can create only a single entry,
|
733
|
+
# with or without a single part of speech, for any word; you cannot create multiple
|
734
|
+
# entries with different parts of speech for the same word. For more information,
|
735
|
+
# see [Working with Japanese
|
736
|
+
# entries](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-rules#jaNotes).
|
742
737
|
# @return [nil]
|
743
|
-
def
|
738
|
+
def add_word(customization_id:, word:, translation:, part_of_speech: nil)
|
744
739
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
745
740
|
|
746
741
|
raise ArgumentError.new("word must be provided") if word.nil?
|
747
742
|
|
743
|
+
raise ArgumentError.new("translation must be provided") if translation.nil?
|
744
|
+
|
748
745
|
headers = {
|
749
746
|
}
|
750
|
-
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "
|
747
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "add_word")
|
751
748
|
headers.merge!(sdk_headers)
|
752
749
|
|
750
|
+
data = {
|
751
|
+
"translation" => translation,
|
752
|
+
"part_of_speech" => part_of_speech
|
753
|
+
}
|
754
|
+
|
753
755
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
|
754
756
|
|
755
757
|
request(
|
756
|
-
method: "
|
758
|
+
method: "PUT",
|
757
759
|
url: method_url,
|
758
760
|
headers: headers,
|
761
|
+
json: data,
|
759
762
|
accept_json: false
|
760
763
|
)
|
761
764
|
nil
|
@@ -771,7 +774,7 @@ module IBMWatson
|
|
771
774
|
# **Note:** This method is currently a beta release.
|
772
775
|
#
|
773
776
|
# **See also:** [Querying a single word from a custom
|
774
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech
|
777
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordQueryModel).
|
775
778
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
776
779
|
# with service credentials created for the instance of the service that owns the
|
777
780
|
# custom model.
|
@@ -799,38 +802,40 @@ module IBMWatson
|
|
799
802
|
end
|
800
803
|
|
801
804
|
##
|
802
|
-
# @!method
|
803
|
-
#
|
804
|
-
#
|
805
|
-
#
|
806
|
-
#
|
807
|
-
# words.
|
805
|
+
# @!method delete_word(customization_id:, word:)
|
806
|
+
# Delete a custom word.
|
807
|
+
# Deletes a single word from the specified custom voice model. You must use
|
808
|
+
# credentials for the instance of the service that owns a model to delete its words.
|
809
|
+
#
|
808
810
|
#
|
809
811
|
# **Note:** This method is currently a beta release.
|
810
812
|
#
|
811
|
-
# **See also:** [
|
812
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech
|
813
|
+
# **See also:** [Deleting a word from a custom
|
814
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-customWords#cuWordDelete).
|
813
815
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
814
816
|
# with service credentials created for the instance of the service that owns the
|
815
817
|
# custom model.
|
816
|
-
# @
|
817
|
-
|
818
|
+
# @param word [String] The word that is to be deleted from the custom voice model.
|
819
|
+
# @return [nil]
|
820
|
+
def delete_word(customization_id:, word:)
|
818
821
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
819
822
|
|
823
|
+
raise ArgumentError.new("word must be provided") if word.nil?
|
824
|
+
|
820
825
|
headers = {
|
821
826
|
}
|
822
|
-
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "
|
827
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "delete_word")
|
823
828
|
headers.merge!(sdk_headers)
|
824
829
|
|
825
|
-
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
830
|
+
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
|
826
831
|
|
827
|
-
|
828
|
-
method: "
|
832
|
+
request(
|
833
|
+
method: "DELETE",
|
829
834
|
url: method_url,
|
830
835
|
headers: headers,
|
831
|
-
accept_json:
|
836
|
+
accept_json: false
|
832
837
|
)
|
833
|
-
|
838
|
+
nil
|
834
839
|
end
|
835
840
|
#########################
|
836
841
|
# User data
|
@@ -849,7 +854,7 @@ module IBMWatson
|
|
849
854
|
# with a request that passes the data.
|
850
855
|
#
|
851
856
|
# **See also:** [Information
|
852
|
-
# security](https://cloud.ibm.com/docs/services/text-to-speech
|
857
|
+
# security](https://cloud.ibm.com/docs/services/text-to-speech?topic=text-to-speech-information-security#information-security).
|
853
858
|
# @param customer_id [String] The customer ID for which all data is to be deleted.
|
854
859
|
# @return [nil]
|
855
860
|
def delete_user_data(customer_id:)
|