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
@@ -36,7 +36,6 @@
|
|
36
36
|
require "concurrent"
|
37
37
|
require "erb"
|
38
38
|
require "json"
|
39
|
-
|
40
39
|
require "ibm_cloud_sdk_core"
|
41
40
|
require_relative "./common.rb"
|
42
41
|
|
@@ -92,32 +91,6 @@ module IBMWatson
|
|
92
91
|
# Voices
|
93
92
|
#########################
|
94
93
|
|
95
|
-
##
|
96
|
-
# @!method list_voices
|
97
|
-
# List voices.
|
98
|
-
# Lists all voices available for use with the service. The information includes the
|
99
|
-
# name, language, gender, and other details about the voice. To see information
|
100
|
-
# about a specific voice, use the **Get a voice** method.
|
101
|
-
#
|
102
|
-
# **See also:** [Specifying a
|
103
|
-
# voice](https://cloud.ibm.com/docs/services/text-to-speech/http.html#voices).
|
104
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
105
|
-
def list_voices
|
106
|
-
headers = {
|
107
|
-
}
|
108
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "text_to_speech", service_version: "V1", operation_id: "list_voices")
|
109
|
-
|
110
|
-
method_url = "/v1/voices"
|
111
|
-
|
112
|
-
response = request(
|
113
|
-
method: "GET",
|
114
|
-
url: method_url,
|
115
|
-
headers: headers,
|
116
|
-
accept_json: true
|
117
|
-
)
|
118
|
-
response
|
119
|
-
end
|
120
|
-
|
121
94
|
##
|
122
95
|
# @!method get_voice(voice:, customization_id: nil)
|
123
96
|
# Get a voice.
|
@@ -126,8 +99,8 @@ module IBMWatson
|
|
126
99
|
# obtain information for that custom voice model of the specified voice. To list
|
127
100
|
# information about all available voices, use the **List voices** method.
|
128
101
|
#
|
129
|
-
# **See also:** [
|
130
|
-
# voice](https://cloud.ibm.com/docs/services/text-to-speech/
|
102
|
+
# **See also:** [Listing a specific
|
103
|
+
# voice](https://cloud.ibm.com/docs/services/text-to-speech/voices.html#listVoice).
|
131
104
|
# @param voice [String] The voice for which information is to be returned.
|
132
105
|
# @param customization_id [String] The customization ID (GUID) of a custom voice model for which information is to be
|
133
106
|
# returned. You must make the request with service credentials created for the
|
@@ -139,7 +112,8 @@ module IBMWatson
|
|
139
112
|
|
140
113
|
headers = {
|
141
114
|
}
|
142
|
-
|
115
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "get_voice")
|
116
|
+
headers.merge!(sdk_headers)
|
143
117
|
|
144
118
|
params = {
|
145
119
|
"customization_id" => customization_id
|
@@ -156,22 +130,50 @@ module IBMWatson
|
|
156
130
|
)
|
157
131
|
response
|
158
132
|
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
|
159
160
|
#########################
|
160
161
|
# Synthesis
|
161
162
|
#########################
|
162
163
|
|
163
164
|
##
|
164
|
-
# @!method synthesize(text:,
|
165
|
+
# @!method synthesize(text:, voice: nil, customization_id: nil, accept: nil)
|
165
166
|
# Synthesize audio.
|
166
167
|
# Synthesizes text to audio that is spoken in the specified voice. The service bases
|
167
168
|
# its understanding of the language for the input text on the specified voice. Use a
|
168
169
|
# voice that matches the language of the input text.
|
169
170
|
#
|
170
|
-
# The
|
171
|
-
#
|
171
|
+
# The method accepts a maximum of 5 KB of input text in the body of the request, and
|
172
|
+
# 8 KB for the URL and headers. The 5 KB limit includes any SSML tags that you
|
173
|
+
# specify. The service returns the synthesized audio stream as an array of bytes.
|
172
174
|
#
|
173
|
-
# **See also:** [
|
174
|
-
#
|
175
|
+
# **See also:** [The HTTP
|
176
|
+
# interface](https://cloud.ibm.com/docs/services/text-to-speech/http.html).
|
175
177
|
#
|
176
178
|
# ### Audio formats (accept types)
|
177
179
|
#
|
@@ -238,8 +240,8 @@ module IBMWatson
|
|
238
240
|
# 22,050 Hz.
|
239
241
|
#
|
240
242
|
# For more information about specifying an audio format, including additional
|
241
|
-
# details about some of the formats, see [
|
242
|
-
#
|
243
|
+
# details about some of the formats, see [Audio
|
244
|
+
# formats](https://cloud.ibm.com/docs/services/text-to-speech/audio-formats.html).
|
243
245
|
#
|
244
246
|
# ### Warning messages
|
245
247
|
#
|
@@ -250,26 +252,27 @@ module IBMWatson
|
|
250
252
|
# arguments:\"` followed by a list of the form `\"{invalid_arg_1},
|
251
253
|
# {invalid_arg_2}.\"` The request succeeds despite the warnings.
|
252
254
|
# @param text [String] The text to synthesize.
|
253
|
-
# @param accept [String] The requested format (MIME type) of the audio. You can use the `Accept` header or
|
254
|
-
# the `accept` parameter to specify the audio format. For more information about
|
255
|
-
# specifying an audio format, see **Audio formats (accept types)** in the method
|
256
|
-
# description.
|
257
|
-
#
|
258
|
-
# Default: `audio/ogg;codecs=opus`.
|
259
255
|
# @param voice [String] The voice to use for synthesis.
|
260
256
|
# @param customization_id [String] The customization ID (GUID) of a custom voice model to use for the synthesis. If a
|
261
257
|
# custom voice model is specified, it is guaranteed to work only if it matches the
|
262
258
|
# language of the indicated voice. You must make the request with service
|
263
259
|
# credentials created for the instance of the service that owns the custom model.
|
264
260
|
# Omit the parameter to use the specified voice with no customization.
|
261
|
+
# @param accept [String] The requested format (MIME type) of the audio. You can use the `Accept` header or
|
262
|
+
# the `accept` parameter to specify the audio format. For more information about
|
263
|
+
# specifying an audio format, see **Audio formats (accept types)** in the method
|
264
|
+
# description.
|
265
|
+
#
|
266
|
+
# Default: `audio/ogg;codecs=opus`.
|
265
267
|
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
266
|
-
def synthesize(text:,
|
268
|
+
def synthesize(text:, voice: nil, customization_id: nil, accept: nil)
|
267
269
|
raise ArgumentError.new("text must be provided") if text.nil?
|
268
270
|
|
269
271
|
headers = {
|
270
272
|
"Accept" => accept
|
271
273
|
}
|
272
|
-
|
274
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "synthesize")
|
275
|
+
headers.merge!(sdk_headers)
|
273
276
|
|
274
277
|
params = {
|
275
278
|
"voice" => voice,
|
@@ -327,7 +330,8 @@ module IBMWatson
|
|
327
330
|
|
328
331
|
headers = {
|
329
332
|
}
|
330
|
-
|
333
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "get_pronunciation")
|
334
|
+
headers.merge!(sdk_headers)
|
331
335
|
|
332
336
|
params = {
|
333
337
|
"text" => text,
|
@@ -374,7 +378,8 @@ module IBMWatson
|
|
374
378
|
|
375
379
|
headers = {
|
376
380
|
}
|
377
|
-
|
381
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "create_voice_model")
|
382
|
+
headers.merge!(sdk_headers)
|
378
383
|
|
379
384
|
data = {
|
380
385
|
"name" => name,
|
@@ -394,6 +399,74 @@ module IBMWatson
|
|
394
399
|
response
|
395
400
|
end
|
396
401
|
|
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
|
+
|
397
470
|
##
|
398
471
|
# @!method list_voice_models(language: nil)
|
399
472
|
# List custom models.
|
@@ -415,7 +488,8 @@ module IBMWatson
|
|
415
488
|
def list_voice_models(language: nil)
|
416
489
|
headers = {
|
417
490
|
}
|
418
|
-
|
491
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "list_voice_models")
|
492
|
+
headers.merge!(sdk_headers)
|
419
493
|
|
420
494
|
params = {
|
421
495
|
"language" => language
|
@@ -480,7 +554,8 @@ module IBMWatson
|
|
480
554
|
|
481
555
|
headers = {
|
482
556
|
}
|
483
|
-
|
557
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "update_voice_model")
|
558
|
+
headers.merge!(sdk_headers)
|
484
559
|
|
485
560
|
data = {
|
486
561
|
"name" => name,
|
@@ -499,75 +574,85 @@ module IBMWatson
|
|
499
574
|
)
|
500
575
|
nil
|
501
576
|
end
|
577
|
+
#########################
|
578
|
+
# Custom words
|
579
|
+
#########################
|
502
580
|
|
503
581
|
##
|
504
|
-
# @!method
|
505
|
-
#
|
506
|
-
#
|
507
|
-
#
|
508
|
-
#
|
509
|
-
#
|
582
|
+
# @!method add_word(customization_id:, word:, translation:, part_of_speech: nil)
|
583
|
+
# Add a custom word.
|
584
|
+
# Adds a single word and its translation to the specified custom voice model. Adding
|
585
|
+
# a new translation for a word that already exists in a custom model overwrites the
|
586
|
+
# word's existing translation. A custom model can contain no more than 20,000
|
587
|
+
# entries. You must use credentials for the instance of the service that owns a
|
588
|
+
# model to add a word to it.
|
510
589
|
#
|
511
|
-
#
|
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
|
512
595
|
#
|
513
|
-
#
|
514
|
-
#
|
515
|
-
#
|
516
|
-
#
|
517
|
-
#
|
518
|
-
#
|
519
|
-
|
520
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
521
|
-
|
522
|
-
headers = {
|
523
|
-
}
|
524
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "text_to_speech", service_version: "V1", operation_id: "get_voice_model")
|
525
|
-
|
526
|
-
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
527
|
-
|
528
|
-
response = request(
|
529
|
-
method: "GET",
|
530
|
-
url: method_url,
|
531
|
-
headers: headers,
|
532
|
-
accept_json: true
|
533
|
-
)
|
534
|
-
response
|
535
|
-
end
|
536
|
-
|
537
|
-
##
|
538
|
-
# @!method delete_voice_model(customization_id:)
|
539
|
-
# Delete a custom model.
|
540
|
-
# Deletes the specified custom voice model. You must use credentials for the
|
541
|
-
# instance of the service that owns a model to delete it.
|
596
|
+
# <code><phoneme alphabet=\"ipa\"
|
597
|
+
# ph=\"təmˈɑto\"></phoneme></code>
|
598
|
+
#
|
599
|
+
# or in the proprietary IBM Symbolic Phonetic Representation (SPR)
|
600
|
+
#
|
601
|
+
# <code><phoneme alphabet=\"ibm\"
|
602
|
+
# ph=\"1gAstroEntxrYFXs\"></phoneme></code>
|
542
603
|
#
|
543
604
|
# **Note:** This method is currently a beta release.
|
544
605
|
#
|
545
|
-
# **See also:**
|
546
|
-
#
|
606
|
+
# **See also:**
|
607
|
+
# * [Adding a single word to a custom
|
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).
|
547
613
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
548
614
|
# with service credentials created for the instance of the service that owns the
|
549
615
|
# 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).
|
550
627
|
# @return [nil]
|
551
|
-
def
|
628
|
+
def add_word(customization_id:, word:, translation:, part_of_speech: nil)
|
552
629
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
553
630
|
|
631
|
+
raise ArgumentError.new("word must be provided") if word.nil?
|
632
|
+
|
633
|
+
raise ArgumentError.new("translation must be provided") if translation.nil?
|
634
|
+
|
554
635
|
headers = {
|
555
636
|
}
|
556
|
-
|
637
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "add_word")
|
638
|
+
headers.merge!(sdk_headers)
|
557
639
|
|
558
|
-
|
640
|
+
data = {
|
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)]
|
559
646
|
|
560
647
|
request(
|
561
|
-
method: "
|
648
|
+
method: "PUT",
|
562
649
|
url: method_url,
|
563
650
|
headers: headers,
|
564
|
-
|
651
|
+
json: data,
|
652
|
+
accept_json: false
|
565
653
|
)
|
566
654
|
nil
|
567
655
|
end
|
568
|
-
#########################
|
569
|
-
# Custom words
|
570
|
-
#########################
|
571
656
|
|
572
657
|
##
|
573
658
|
# @!method add_words(customization_id:, words:)
|
@@ -620,7 +705,8 @@ module IBMWatson
|
|
620
705
|
|
621
706
|
headers = {
|
622
707
|
}
|
623
|
-
|
708
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "add_words")
|
709
|
+
headers.merge!(sdk_headers)
|
624
710
|
|
625
711
|
data = {
|
626
712
|
"words" => words
|
@@ -639,110 +725,38 @@ module IBMWatson
|
|
639
725
|
end
|
640
726
|
|
641
727
|
##
|
642
|
-
# @!method
|
643
|
-
#
|
644
|
-
#
|
645
|
-
#
|
646
|
-
# must use credentials for the instance of the service that owns a model to list its
|
647
|
-
# words.
|
648
|
-
#
|
649
|
-
# **Note:** This method is currently a beta release.
|
650
|
-
#
|
651
|
-
# **See also:** [Querying all words from a custom
|
652
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordsQueryModel).
|
653
|
-
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
654
|
-
# with service credentials created for the instance of the service that owns the
|
655
|
-
# custom model.
|
656
|
-
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
657
|
-
def list_words(customization_id:)
|
658
|
-
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
659
|
-
|
660
|
-
headers = {
|
661
|
-
}
|
662
|
-
headers = Common.new.get_sdk_headers(headers: headers, service_name: "text_to_speech", service_version: "V1", operation_id: "list_words")
|
663
|
-
|
664
|
-
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
665
|
-
|
666
|
-
response = request(
|
667
|
-
method: "GET",
|
668
|
-
url: method_url,
|
669
|
-
headers: headers,
|
670
|
-
accept_json: true
|
671
|
-
)
|
672
|
-
response
|
673
|
-
end
|
674
|
-
|
675
|
-
##
|
676
|
-
# @!method add_word(customization_id:, word:, translation:, part_of_speech: nil)
|
677
|
-
# Add a custom word.
|
678
|
-
# Adds a single word and its translation to the specified custom voice model. Adding
|
679
|
-
# a new translation for a word that already exists in a custom model overwrites the
|
680
|
-
# word's existing translation. A custom model can contain no more than 20,000
|
681
|
-
# entries. You must use credentials for the instance of the service that owns a
|
682
|
-
# model to add a word to it.
|
683
|
-
#
|
684
|
-
# You can define sounds-like or phonetic translations for words. A sounds-like
|
685
|
-
# translation consists of one or more words that, when combined, sound like the
|
686
|
-
# word. Phonetic translations are based on the SSML phoneme format for representing
|
687
|
-
# a word. You can specify them in standard International Phonetic Alphabet (IPA)
|
688
|
-
# representation
|
689
|
-
#
|
690
|
-
# <code><phoneme alphabet=\"ipa\"
|
691
|
-
# ph=\"təmˈɑto\"></phoneme></code>
|
728
|
+
# @!method delete_word(customization_id:, word:)
|
729
|
+
# Delete a custom word.
|
730
|
+
# Deletes a single word from the specified custom voice model. You must use
|
731
|
+
# credentials for the instance of the service that owns a model to delete its words.
|
692
732
|
#
|
693
|
-
# or in the proprietary IBM Symbolic Phonetic Representation (SPR)
|
694
|
-
#
|
695
|
-
# <code><phoneme alphabet=\"ibm\"
|
696
|
-
# ph=\"1gAstroEntxrYFXs\"></phoneme></code>
|
697
733
|
#
|
698
734
|
# **Note:** This method is currently a beta release.
|
699
735
|
#
|
700
|
-
# **See also:**
|
701
|
-
#
|
702
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordAdd)
|
703
|
-
# * [Adding words to a Japanese custom
|
704
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuJapaneseAdd)
|
705
|
-
# * [Understanding
|
706
|
-
# customization](https://cloud.ibm.com/docs/services/text-to-speech/custom-intro.html).
|
736
|
+
# **See also:** [Deleting a word from a custom
|
737
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordDelete).
|
707
738
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
708
739
|
# with service credentials created for the instance of the service that owns the
|
709
740
|
# custom model.
|
710
|
-
# @param word [String] The word that is to be
|
711
|
-
# @param translation [String] The phonetic or sounds-like translation for the word. A phonetic translation is
|
712
|
-
# based on the SSML format for representing the phonetic string of a word either as
|
713
|
-
# an IPA translation or as an IBM SPR translation. A sounds-like is one or more
|
714
|
-
# words that, when combined, sound like the word.
|
715
|
-
# @param part_of_speech [String] **Japanese only.** The part of speech for the word. The service uses the value to
|
716
|
-
# produce the correct intonation for the word. You can create only a single entry,
|
717
|
-
# with or without a single part of speech, for any word; you cannot create multiple
|
718
|
-
# entries with different parts of speech for the same word. For more information,
|
719
|
-
# see [Working with Japanese
|
720
|
-
# entries](https://cloud.ibm.com/docs/services/text-to-speech/custom-rules.html#jaNotes).
|
741
|
+
# @param word [String] The word that is to be deleted from the custom voice model.
|
721
742
|
# @return [nil]
|
722
|
-
def
|
743
|
+
def delete_word(customization_id:, word:)
|
723
744
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
724
745
|
|
725
746
|
raise ArgumentError.new("word must be provided") if word.nil?
|
726
747
|
|
727
|
-
raise ArgumentError.new("translation must be provided") if translation.nil?
|
728
|
-
|
729
748
|
headers = {
|
730
749
|
}
|
731
|
-
|
732
|
-
|
733
|
-
data = {
|
734
|
-
"translation" => translation,
|
735
|
-
"part_of_speech" => part_of_speech
|
736
|
-
}
|
750
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "delete_word")
|
751
|
+
headers.merge!(sdk_headers)
|
737
752
|
|
738
753
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
|
739
754
|
|
740
755
|
request(
|
741
|
-
method: "
|
756
|
+
method: "DELETE",
|
742
757
|
url: method_url,
|
743
758
|
headers: headers,
|
744
|
-
|
745
|
-
accept_json: true
|
759
|
+
accept_json: false
|
746
760
|
)
|
747
761
|
nil
|
748
762
|
end
|
@@ -770,7 +784,8 @@ module IBMWatson
|
|
770
784
|
|
771
785
|
headers = {
|
772
786
|
}
|
773
|
-
|
787
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "get_word")
|
788
|
+
headers.merge!(sdk_headers)
|
774
789
|
|
775
790
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word)]
|
776
791
|
|
@@ -784,39 +799,38 @@ module IBMWatson
|
|
784
799
|
end
|
785
800
|
|
786
801
|
##
|
787
|
-
# @!method
|
788
|
-
#
|
789
|
-
#
|
790
|
-
#
|
791
|
-
#
|
802
|
+
# @!method list_words(customization_id:)
|
803
|
+
# List custom words.
|
804
|
+
# Lists all of the words and their translations for the specified custom voice
|
805
|
+
# model. The output shows the translations as they are defined in the model. You
|
806
|
+
# must use credentials for the instance of the service that owns a model to list its
|
807
|
+
# words.
|
792
808
|
#
|
793
809
|
# **Note:** This method is currently a beta release.
|
794
810
|
#
|
795
|
-
# **See also:** [
|
796
|
-
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#
|
811
|
+
# **See also:** [Querying all words from a custom
|
812
|
+
# model](https://cloud.ibm.com/docs/services/text-to-speech/custom-entries.html#cuWordsQueryModel).
|
797
813
|
# @param customization_id [String] The customization ID (GUID) of the custom voice model. You must make the request
|
798
814
|
# with service credentials created for the instance of the service that owns the
|
799
815
|
# custom model.
|
800
|
-
# @
|
801
|
-
|
802
|
-
def delete_word(customization_id:, word:)
|
816
|
+
# @return [IBMCloudSdkCore::DetailedResponse] A `IBMCloudSdkCore::DetailedResponse` object representing the response.
|
817
|
+
def list_words(customization_id:)
|
803
818
|
raise ArgumentError.new("customization_id must be provided") if customization_id.nil?
|
804
819
|
|
805
|
-
raise ArgumentError.new("word must be provided") if word.nil?
|
806
|
-
|
807
820
|
headers = {
|
808
821
|
}
|
809
|
-
|
822
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "list_words")
|
823
|
+
headers.merge!(sdk_headers)
|
810
824
|
|
811
|
-
method_url = "/v1/customizations/%s/words
|
825
|
+
method_url = "/v1/customizations/%s/words" % [ERB::Util.url_encode(customization_id)]
|
812
826
|
|
813
|
-
request(
|
814
|
-
method: "
|
827
|
+
response = request(
|
828
|
+
method: "GET",
|
815
829
|
url: method_url,
|
816
830
|
headers: headers,
|
817
831
|
accept_json: true
|
818
832
|
)
|
819
|
-
|
833
|
+
response
|
820
834
|
end
|
821
835
|
#########################
|
822
836
|
# User data
|
@@ -843,7 +857,8 @@ module IBMWatson
|
|
843
857
|
|
844
858
|
headers = {
|
845
859
|
}
|
846
|
-
|
860
|
+
sdk_headers = Common.new.get_sdk_headers("text_to_speech", "V1", "delete_user_data")
|
861
|
+
headers.merge!(sdk_headers)
|
847
862
|
|
848
863
|
params = {
|
849
864
|
"customer_id" => customer_id
|
@@ -856,7 +871,7 @@ module IBMWatson
|
|
856
871
|
url: method_url,
|
857
872
|
headers: headers,
|
858
873
|
params: params,
|
859
|
-
accept_json:
|
874
|
+
accept_json: false
|
860
875
|
)
|
861
876
|
nil
|
862
877
|
end
|