ibm_watson 0.20.1 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -60
- data/lib/ibm_watson.rb +0 -2
- data/lib/ibm_watson/assistant_v1.rb +82 -60
- data/lib/ibm_watson/assistant_v2.rb +8 -12
- data/lib/ibm_watson/compare_comply_v1.rb +21 -18
- data/lib/ibm_watson/discovery_v1.rb +107 -55
- data/lib/ibm_watson/language_translator_v3.rb +21 -23
- data/lib/ibm_watson/natural_language_classifier_v1.rb +15 -24
- data/lib/ibm_watson/natural_language_understanding_v1.rb +8 -12
- data/lib/ibm_watson/personality_insights_v3.rb +12 -24
- data/lib/ibm_watson/speech_to_text_v1.rb +90 -54
- data/lib/ibm_watson/text_to_speech_v1.rb +38 -32
- data/lib/ibm_watson/tone_analyzer_v3.rb +13 -24
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +37 -25
- data/test/integration/test_assistant_v1.rb +8 -4
- data/test/integration/test_assistant_v2.rb +6 -1
- data/test/integration/test_compare_comply_v1.rb +6 -2
- data/test/integration/test_discovery_v1.rb +4 -1
- data/test/integration/test_language_translator_v3.rb +4 -16
- data/test/integration/test_natural_language_classifier_v1.rb +4 -1
- data/test/integration/test_natural_language_understanding_v1.rb +4 -1
- data/test/integration/test_personality_insights_v3.rb +5 -2
- data/test/integration/test_speech_to_text_v1.rb +9 -3
- data/test/integration/test_text_to_speech_v1.rb +5 -2
- data/test/integration/test_tone_analyzer_v3.rb +5 -2
- data/test/integration/test_visual_recognition_v3.rb +5 -2
- data/test/test_helper.rb +2 -0
- data/test/unit/test_assistant_v1.rb +269 -133
- data/test/unit/test_assistant_v2.rb +18 -9
- data/test/unit/test_compare_comply_v1.rb +72 -40
- data/test/unit/test_configure_http_client.rb +4 -2
- data/test/unit/test_discovery_v1.rb +297 -152
- data/test/unit/test_language_translator_v3.rb +52 -13
- data/test/unit/test_natural_language_classifier_v1.rb +10 -4
- data/test/unit/test_natural_language_understanding_v1.rb +25 -10
- data/test/unit/test_personality_insights_v3.rb +20 -8
- data/test/unit/test_speech_to_text_v1.rb +84 -21
- data/test/unit/test_text_to_speech_v1.rb +30 -5
- data/test/unit/test_tone_analyzer_v3.rb +30 -12
- data/test/unit/test_vcap_using_personality_insights.rb +12 -4
- data/test/unit/test_visual_recognition_v3.rb +37 -10
- metadata +8 -8
- data/test/unit/test_watson_service.rb +0 -59
@@ -49,9 +49,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
49
49
|
body: token_response.to_json,
|
50
50
|
headers: {}
|
51
51
|
)
|
52
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
53
|
+
apikey: "iam_apikey"
|
54
|
+
)
|
52
55
|
service = IBMWatson::LanguageTranslatorV3.new(
|
53
56
|
version: "2018-05-01",
|
54
|
-
|
57
|
+
authenticator: authenticator
|
55
58
|
)
|
56
59
|
expected = {
|
57
60
|
"character_count" => 19,
|
@@ -92,9 +95,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
92
95
|
body: token_response.to_json,
|
93
96
|
headers: {}
|
94
97
|
)
|
98
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
99
|
+
apikey: "iam_apikey"
|
100
|
+
)
|
95
101
|
service = IBMWatson::LanguageTranslatorV3.new(
|
96
102
|
version: "2018-05-01",
|
97
|
-
|
103
|
+
authenticator: authenticator
|
98
104
|
)
|
99
105
|
expected = {
|
100
106
|
"character_count" => 22,
|
@@ -138,9 +144,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
138
144
|
body: token_response.to_json,
|
139
145
|
headers: {}
|
140
146
|
)
|
147
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
148
|
+
apikey: "iam_apikey"
|
149
|
+
)
|
141
150
|
service = IBMWatson::LanguageTranslatorV3.new(
|
142
151
|
version: "2018-05-01",
|
143
|
-
|
152
|
+
authenticator: authenticator
|
144
153
|
)
|
145
154
|
expected = {
|
146
155
|
"languages" => [
|
@@ -190,9 +199,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
190
199
|
body: token_response.to_json,
|
191
200
|
headers: {}
|
192
201
|
)
|
202
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
203
|
+
apikey: "iam_apikey"
|
204
|
+
)
|
193
205
|
service = IBMWatson::LanguageTranslatorV3.new(
|
194
206
|
version: "2018-05-01",
|
195
|
-
|
207
|
+
authenticator: authenticator
|
196
208
|
)
|
197
209
|
expected = {
|
198
210
|
"languages" => [
|
@@ -249,9 +261,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
249
261
|
body: token_response.to_json,
|
250
262
|
headers: {}
|
251
263
|
)
|
264
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
265
|
+
apikey: "iam_apikey"
|
266
|
+
)
|
252
267
|
service = IBMWatson::LanguageTranslatorV3.new(
|
253
268
|
version: "2018-05-01",
|
254
|
-
|
269
|
+
authenticator: authenticator
|
255
270
|
)
|
256
271
|
expected = {
|
257
272
|
"status" => "available",
|
@@ -314,9 +329,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
314
329
|
body: token_response.to_json,
|
315
330
|
headers: {}
|
316
331
|
)
|
332
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
333
|
+
apikey: "iam_apikey"
|
334
|
+
)
|
317
335
|
service = IBMWatson::LanguageTranslatorV3.new(
|
318
336
|
version: "2018-05-01",
|
319
|
-
|
337
|
+
authenticator: authenticator
|
320
338
|
)
|
321
339
|
expected = {
|
322
340
|
"status" => "OK"
|
@@ -351,9 +369,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
351
369
|
body: token_response.to_json,
|
352
370
|
headers: {}
|
353
371
|
)
|
372
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
373
|
+
apikey: "iam_apikey"
|
374
|
+
)
|
354
375
|
service = IBMWatson::LanguageTranslatorV3.new(
|
355
376
|
version: "2018-05-01",
|
356
|
-
|
377
|
+
authenticator: authenticator
|
357
378
|
)
|
358
379
|
expected = {
|
359
380
|
"status" => "available",
|
@@ -397,9 +418,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
397
418
|
body: token.to_json,
|
398
419
|
headers: {}
|
399
420
|
)
|
421
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
422
|
+
apikey: "iam_apikey"
|
423
|
+
)
|
400
424
|
service = IBMWatson::LanguageTranslatorV3.new(
|
401
425
|
version: "2018-05-01",
|
402
|
-
|
426
|
+
authenticator: authenticator
|
403
427
|
)
|
404
428
|
expected = {
|
405
429
|
"models" => [
|
@@ -457,9 +481,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
457
481
|
body: token_response.to_json,
|
458
482
|
headers: {}
|
459
483
|
)
|
484
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
485
|
+
apikey: "iam_apikey"
|
486
|
+
)
|
460
487
|
service = IBMWatson::LanguageTranslatorV3.new(
|
461
488
|
version: "2018-05-01",
|
462
|
-
|
489
|
+
authenticator: authenticator
|
463
490
|
)
|
464
491
|
expected = {}
|
465
492
|
stub_request(:get, "https://gateway.watsonplatform.net/language-translator/api/v3/documents?version=2018-05-01")
|
@@ -490,9 +517,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
490
517
|
body: token_response.to_json,
|
491
518
|
headers: {}
|
492
519
|
)
|
520
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
521
|
+
apikey: "iam_apikey"
|
522
|
+
)
|
493
523
|
service = IBMWatson::LanguageTranslatorV3.new(
|
494
524
|
version: "2018-05-01",
|
495
|
-
|
525
|
+
authenticator: authenticator
|
496
526
|
)
|
497
527
|
stub_request(:post, "https://gateway.watsonplatform.net/language-translator/api/v3/documents?version=2018-05-01")
|
498
528
|
.with do |req|
|
@@ -519,9 +549,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
519
549
|
body: token_response.to_json,
|
520
550
|
headers: {}
|
521
551
|
)
|
552
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
553
|
+
apikey: "iam_apikey"
|
554
|
+
)
|
522
555
|
service = IBMWatson::LanguageTranslatorV3.new(
|
523
556
|
version: "2018-05-01",
|
524
|
-
|
557
|
+
authenticator: authenticator
|
525
558
|
)
|
526
559
|
expected = {}
|
527
560
|
stub_request(:get, "https://gateway.watsonplatform.net/language-translator/api/v3/documents/id?version=2018-05-01")
|
@@ -552,9 +585,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
552
585
|
body: token_response.to_json,
|
553
586
|
headers: {}
|
554
587
|
)
|
588
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
589
|
+
apikey: "iam_apikey"
|
590
|
+
)
|
555
591
|
service = IBMWatson::LanguageTranslatorV3.new(
|
556
592
|
version: "2018-05-01",
|
557
|
-
|
593
|
+
authenticator: authenticator
|
558
594
|
)
|
559
595
|
expected = {}
|
560
596
|
stub_request(:get, "https://gateway.watsonplatform.net/language-translator/api/v3/documents/id/translated_document?version=2018-05-01")
|
@@ -585,9 +621,12 @@ class LanguageTranslatorV3Test < Minitest::Test
|
|
585
621
|
body: token_response.to_json,
|
586
622
|
headers: {}
|
587
623
|
)
|
624
|
+
authenticator = IBMCloudSdkCore::IamAuthenticator.new(
|
625
|
+
apikey: "iam_apikey"
|
626
|
+
)
|
588
627
|
service = IBMWatson::LanguageTranslatorV3.new(
|
589
628
|
version: "2018-05-01",
|
590
|
-
|
629
|
+
authenticator: authenticator
|
591
630
|
)
|
592
631
|
expected = {}
|
593
632
|
stub_request(:delete, "https://gateway.watsonplatform.net/language-translator/api/v3/documents/id?version=2018-05-01")
|
@@ -9,10 +9,13 @@ WebMock.disable_net_connect!(allow_localhost: true)
|
|
9
9
|
# Unit tests for the Natural Language Classifier V1 Service
|
10
10
|
class NaturalLanguageClassifierV1Test < Minitest::Test
|
11
11
|
def test_success
|
12
|
-
|
12
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
13
13
|
username: "username",
|
14
14
|
password: "password"
|
15
15
|
)
|
16
|
+
service = IBMWatson::NaturalLanguageClassifierV1.new(
|
17
|
+
authenticator: authenticator
|
18
|
+
)
|
16
19
|
list_response = {
|
17
20
|
"classifiers" => [
|
18
21
|
{
|
@@ -101,13 +104,13 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
101
104
|
training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
|
102
105
|
service_response = service.create_classifier(
|
103
106
|
training_data: training_data,
|
104
|
-
|
107
|
+
training_metadata: { "language" => "en" }
|
105
108
|
)
|
106
109
|
assert_equal(create_response, service_response.result)
|
107
110
|
|
108
111
|
service_response = service.create_classifier(
|
109
112
|
training_data: { "training" => "data" },
|
110
|
-
|
113
|
+
training_metadata: { "language" => "en" }
|
111
114
|
)
|
112
115
|
assert_equal(create_response, service_response.result)
|
113
116
|
|
@@ -126,10 +129,13 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
126
129
|
end
|
127
130
|
|
128
131
|
def test_classify_collection
|
129
|
-
|
132
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
130
133
|
username: "username",
|
131
134
|
password: "password"
|
132
135
|
)
|
136
|
+
service = IBMWatson::NaturalLanguageClassifierV1.new(
|
137
|
+
authenticator: authenticator
|
138
|
+
)
|
133
139
|
classify_collection_response = {
|
134
140
|
"classifier_id" => "497EF2-nlc-00",
|
135
141
|
"url" => "https://gateway.watsonplatform.net/natural-language-classifier/api/v1/classifiers/10D41B-nlc-1",
|
@@ -9,11 +9,14 @@ WebMock.disable_net_connect!(allow_localhost: true)
|
|
9
9
|
# Unit tests for the Natural Language Understanding V1 Service
|
10
10
|
class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
11
11
|
def test_text_analyze
|
12
|
-
|
13
|
-
version: "2018-03-16",
|
12
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
14
13
|
username: "username",
|
15
14
|
password: "password"
|
16
15
|
)
|
16
|
+
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
17
|
+
version: "2018-03-16",
|
18
|
+
authenticator: authenticator
|
19
|
+
)
|
17
20
|
stub_request(:post, "https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-03-16")
|
18
21
|
.with(
|
19
22
|
body: "{\"features\":{\"sentiment\":{}},\"text\":\"hello this is a test\"}",
|
@@ -34,11 +37,14 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
34
37
|
end
|
35
38
|
|
36
39
|
def test_html_analyze
|
37
|
-
|
38
|
-
version: "2018-03-16",
|
40
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
39
41
|
username: "username",
|
40
42
|
password: "password"
|
41
43
|
)
|
44
|
+
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
45
|
+
version: "2018-03-16",
|
46
|
+
authenticator: authenticator
|
47
|
+
)
|
42
48
|
stub_request(:post, "https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-03-16")
|
43
49
|
.with(
|
44
50
|
body: "{\"features\":{\"sentiment\":{},\"emotion\":{\"document\":false}},\"html\":\"<span>hello this is a test </span>\"}",
|
@@ -62,11 +68,14 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
62
68
|
end
|
63
69
|
|
64
70
|
def test_url_analyze
|
65
|
-
|
66
|
-
version: "2018-03-16",
|
71
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
67
72
|
username: "username",
|
68
73
|
password: "password"
|
69
74
|
)
|
75
|
+
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
76
|
+
version: "2018-03-16",
|
77
|
+
authenticator: authenticator
|
78
|
+
)
|
70
79
|
stub_request(:post, "https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-03-16")
|
71
80
|
.with(
|
72
81
|
body: "{\"features\":{\"sentiment\":{},\"emotion\":{\"document\":false}},\"url\":\"http://cnn.com\",\"xpath\":\"/bogus/xpath\",\"language\":\"en\"}",
|
@@ -92,11 +101,14 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
92
101
|
end
|
93
102
|
|
94
103
|
def test_list_models
|
95
|
-
|
96
|
-
version: "2018-03-16",
|
104
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
97
105
|
username: "username",
|
98
106
|
password: "password"
|
99
107
|
)
|
108
|
+
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
109
|
+
version: "2018-03-16",
|
110
|
+
authenticator: authenticator
|
111
|
+
)
|
100
112
|
stub_request(:get, "https://gateway.watsonplatform.net/natural-language-understanding/api/v1/models?version=2018-03-16")
|
101
113
|
.with(
|
102
114
|
headers: {
|
@@ -111,11 +123,14 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
111
123
|
|
112
124
|
def test_delete_model
|
113
125
|
model_id = "invalid_model_id"
|
114
|
-
|
115
|
-
version: "2018-03-16",
|
126
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
116
127
|
username: "username",
|
117
128
|
password: "password"
|
118
129
|
)
|
130
|
+
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
131
|
+
version: "2018-03-16",
|
132
|
+
authenticator: authenticator
|
133
|
+
)
|
119
134
|
stub_request(:delete, "https://gateway.watsonplatform.net/natural-language-understanding/api/v1/models/invalid_model_id?version=2018-03-16")
|
120
135
|
.with(
|
121
136
|
headers: {
|
@@ -25,11 +25,14 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
25
25
|
"Host" => "gateway.watsonplatform.net"
|
26
26
|
}
|
27
27
|
).to_return(status: 200, body: profile_response, headers: headers)
|
28
|
-
|
29
|
-
version: "2017-10-13",
|
28
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
30
29
|
username: "username",
|
31
30
|
password: "password"
|
32
31
|
)
|
32
|
+
service = IBMWatson::PersonalityInsightsV3.new(
|
33
|
+
version: "2017-10-13",
|
34
|
+
authenticator: authenticator
|
35
|
+
)
|
33
36
|
service_response = service.profile(
|
34
37
|
accept: "application/json",
|
35
38
|
content: personality_text,
|
@@ -77,11 +80,14 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
77
80
|
"Host" => "gateway.watsonplatform.net"
|
78
81
|
}
|
79
82
|
).to_return(status: 200, body: profile_response, headers: headers)
|
80
|
-
|
81
|
-
version: "2017-10-13",
|
83
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
82
84
|
username: "username",
|
83
85
|
password: "password"
|
84
86
|
)
|
87
|
+
service = IBMWatson::PersonalityInsightsV3.new(
|
88
|
+
version: "2017-10-13",
|
89
|
+
authenticator: authenticator
|
90
|
+
)
|
85
91
|
service_response = service.profile(
|
86
92
|
accept: "application/json",
|
87
93
|
content: personality_text,
|
@@ -114,11 +120,14 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
114
120
|
"Host" => "gateway.watsonplatform.net"
|
115
121
|
}
|
116
122
|
).to_return(status: 200, body: profile_response, headers: headers)
|
117
|
-
|
118
|
-
version: "2017-10-13",
|
123
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
119
124
|
username: "username",
|
120
125
|
password: "password"
|
121
126
|
)
|
127
|
+
service = IBMWatson::PersonalityInsightsV3.new(
|
128
|
+
version: "2017-10-13",
|
129
|
+
authenticator: authenticator
|
130
|
+
)
|
122
131
|
service_response = service.profile(
|
123
132
|
content: personality_text,
|
124
133
|
content_type: "application/json",
|
@@ -154,11 +163,14 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
154
163
|
"Host" => "gateway.watsonplatform.net"
|
155
164
|
}
|
156
165
|
).to_return(status: 200, body: profile_response.to_json, headers: headers)
|
157
|
-
|
158
|
-
version: "2017-10-13",
|
166
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
159
167
|
username: "username",
|
160
168
|
password: "password"
|
161
169
|
)
|
170
|
+
service = IBMWatson::PersonalityInsightsV3.new(
|
171
|
+
version: "2017-10-13",
|
172
|
+
authenticator: authenticator
|
173
|
+
)
|
162
174
|
service_response = service.profile(
|
163
175
|
accept: "application/json",
|
164
176
|
content: personality_text,
|
@@ -36,10 +36,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
36
36
|
}
|
37
37
|
]
|
38
38
|
}
|
39
|
-
|
39
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
40
40
|
username: "username",
|
41
41
|
password: "password"
|
42
42
|
)
|
43
|
+
service = IBMWatson::SpeechToTextV1.new(
|
44
|
+
authenticator: authenticator
|
45
|
+
)
|
43
46
|
stub_request(:get, "https://stream.watsonplatform.net/speech-to-text/api/v1/models")
|
44
47
|
.with(
|
45
48
|
headers: {
|
@@ -90,10 +93,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
90
93
|
end
|
91
94
|
|
92
95
|
def test_recognize_using_websocket_disable_ssl_verification
|
93
|
-
|
96
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
94
97
|
username: "username",
|
95
98
|
password: "password"
|
96
99
|
)
|
100
|
+
service = IBMWatson::SpeechToTextV1.new(
|
101
|
+
authenticator: authenticator
|
102
|
+
)
|
97
103
|
|
98
104
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
99
105
|
stub_request(:post, "ws://stream.watsonplatform.net/speech-to-text/api/v1/recognize")
|
@@ -121,10 +127,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
121
127
|
end
|
122
128
|
|
123
129
|
def test_get_model
|
124
|
-
|
130
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
125
131
|
username: "username",
|
126
132
|
password: "password"
|
127
133
|
)
|
134
|
+
service = IBMWatson::SpeechToTextV1.new(
|
135
|
+
authenticator: authenticator
|
136
|
+
)
|
128
137
|
stub_request(:get, "https://stream.watsonplatform.net/speech-to-text/api/v1/models/modelid")
|
129
138
|
.with(
|
130
139
|
headers: {
|
@@ -150,10 +159,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
150
159
|
}
|
151
160
|
]
|
152
161
|
}
|
153
|
-
|
162
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
154
163
|
username: "username",
|
155
164
|
password: "password"
|
156
165
|
)
|
166
|
+
service = IBMWatson::SpeechToTextV1.new(
|
167
|
+
authenticator: authenticator
|
168
|
+
)
|
157
169
|
stub_request(:get, "https://stream.watsonplatform.net/speech-to-text/api/v1/recognitions")
|
158
170
|
.with(
|
159
171
|
headers: {
|
@@ -208,10 +220,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
208
220
|
end
|
209
221
|
|
210
222
|
def test_callbacks
|
211
|
-
|
223
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
212
224
|
username: "username",
|
213
225
|
password: "password"
|
214
226
|
)
|
227
|
+
service = IBMWatson::SpeechToTextV1.new(
|
228
|
+
authenticator: authenticator
|
229
|
+
)
|
215
230
|
stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/register_callback?callback_url=monitorcalls.com")
|
216
231
|
.with(
|
217
232
|
headers: {
|
@@ -238,10 +253,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
238
253
|
end
|
239
254
|
|
240
255
|
def test_custom_model
|
241
|
-
|
256
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
242
257
|
username: "username",
|
243
258
|
password: "password"
|
244
259
|
)
|
260
|
+
service = IBMWatson::SpeechToTextV1.new(
|
261
|
+
authenticator: authenticator
|
262
|
+
)
|
245
263
|
stub_request(:get, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations")
|
246
264
|
.with(
|
247
265
|
headers: {
|
@@ -310,10 +328,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
310
328
|
end
|
311
329
|
|
312
330
|
def test_acoustic_model
|
313
|
-
|
331
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
314
332
|
username: "username",
|
315
333
|
password: "password"
|
316
334
|
)
|
335
|
+
service = IBMWatson::SpeechToTextV1.new(
|
336
|
+
authenticator: authenticator
|
337
|
+
)
|
317
338
|
stub_request(:get, "https://stream.watsonplatform.net/speech-to-text/api/v1/acoustic_customizations")
|
318
339
|
.with(
|
319
340
|
headers: {
|
@@ -383,10 +404,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
383
404
|
end
|
384
405
|
|
385
406
|
def test_custom_corpora
|
386
|
-
|
407
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
387
408
|
username: "username",
|
388
409
|
password: "password"
|
389
410
|
)
|
411
|
+
service = IBMWatson::SpeechToTextV1.new(
|
412
|
+
authenticator: authenticator
|
413
|
+
)
|
390
414
|
stub_request(:get, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/customid/corpora")
|
391
415
|
.with(
|
392
416
|
headers: {
|
@@ -452,10 +476,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
452
476
|
end
|
453
477
|
|
454
478
|
def test_custom_words
|
455
|
-
|
479
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
456
480
|
username: "username",
|
457
481
|
password: "password"
|
458
482
|
)
|
483
|
+
service = IBMWatson::SpeechToTextV1.new(
|
484
|
+
authenticator: authenticator
|
485
|
+
)
|
459
486
|
stub_request(:put, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/custid/words/IEEE")
|
460
487
|
.with(
|
461
488
|
body: "{\"sounds_like\":[\"i triple e\"],\"display_as\":\"IEEE\"}",
|
@@ -596,10 +623,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
596
623
|
end
|
597
624
|
|
598
625
|
def test_list_grammars
|
599
|
-
|
626
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
600
627
|
username: "username",
|
601
628
|
password: "password"
|
602
629
|
)
|
630
|
+
service = IBMWatson::SpeechToTextV1.new(
|
631
|
+
authenticator: authenticator
|
632
|
+
)
|
603
633
|
stub_request(:get, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/custid/grammars")
|
604
634
|
.with(
|
605
635
|
headers: {
|
@@ -615,10 +645,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
615
645
|
end
|
616
646
|
|
617
647
|
def test_add_grammar
|
618
|
-
|
648
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
619
649
|
username: "username",
|
620
650
|
password: "password"
|
621
651
|
)
|
652
|
+
service = IBMWatson::SpeechToTextV1.new(
|
653
|
+
authenticator: authenticator
|
654
|
+
)
|
622
655
|
stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/custid/grammars/grammar")
|
623
656
|
.with(
|
624
657
|
headers: {
|
@@ -637,10 +670,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
637
670
|
end
|
638
671
|
|
639
672
|
def test_get_grammar
|
640
|
-
|
673
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
641
674
|
username: "username",
|
642
675
|
password: "password"
|
643
676
|
)
|
677
|
+
service = IBMWatson::SpeechToTextV1.new(
|
678
|
+
authenticator: authenticator
|
679
|
+
)
|
644
680
|
stub_request(:get, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/custid/grammars/grammar")
|
645
681
|
.with(
|
646
682
|
headers: {
|
@@ -657,10 +693,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
657
693
|
end
|
658
694
|
|
659
695
|
def test_delete_grammar
|
660
|
-
|
696
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
661
697
|
username: "username",
|
662
698
|
password: "password"
|
663
699
|
)
|
700
|
+
service = IBMWatson::SpeechToTextV1.new(
|
701
|
+
authenticator: authenticator
|
702
|
+
)
|
664
703
|
stub_request(:delete, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/custid/grammars/grammar")
|
665
704
|
.with(
|
666
705
|
headers: {
|
@@ -677,10 +716,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
677
716
|
end
|
678
717
|
|
679
718
|
def test_custom_audio_resources
|
680
|
-
|
719
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
681
720
|
username: "username",
|
682
721
|
password: "password"
|
683
722
|
)
|
723
|
+
service = IBMWatson::SpeechToTextV1.new(
|
724
|
+
authenticator: authenticator
|
725
|
+
)
|
684
726
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
685
727
|
stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/acoustic_customizations/custid/audio/hiee")
|
686
728
|
.with(
|
@@ -742,10 +784,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
742
784
|
end
|
743
785
|
|
744
786
|
def test_delete_user_data
|
745
|
-
|
787
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
746
788
|
username: "username",
|
747
789
|
password: "password"
|
748
790
|
)
|
791
|
+
service = IBMWatson::SpeechToTextV1.new(
|
792
|
+
authenticator: authenticator
|
793
|
+
)
|
749
794
|
stub_request(:delete, "https://stream.watsonplatform.net/speech-to-text/api/v1/user_data?customer_id=id")
|
750
795
|
.with(
|
751
796
|
headers: {
|
@@ -760,10 +805,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
760
805
|
end
|
761
806
|
|
762
807
|
def test_recognize_await
|
763
|
-
|
808
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
764
809
|
username: "username",
|
765
810
|
password: "password"
|
766
811
|
)
|
812
|
+
service = IBMWatson::SpeechToTextV1.new(
|
813
|
+
authenticator: authenticator
|
814
|
+
)
|
767
815
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
768
816
|
recognize_response = {
|
769
817
|
"results" => [
|
@@ -796,10 +844,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
796
844
|
end
|
797
845
|
|
798
846
|
def test_recognize_async
|
799
|
-
|
847
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
800
848
|
username: "username",
|
801
849
|
password: "password"
|
802
850
|
)
|
851
|
+
service = IBMWatson::SpeechToTextV1.new(
|
852
|
+
authenticator: authenticator
|
853
|
+
)
|
803
854
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
804
855
|
recognize_response = {
|
805
856
|
"results" => [
|
@@ -833,10 +884,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
833
884
|
end
|
834
885
|
|
835
886
|
def test_reset_language_model
|
836
|
-
|
887
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
837
888
|
username: "username",
|
838
889
|
password: "password"
|
839
890
|
)
|
891
|
+
service = IBMWatson::SpeechToTextV1.new(
|
892
|
+
authenticator: authenticator
|
893
|
+
)
|
840
894
|
stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/customization_id/reset")
|
841
895
|
.with(
|
842
896
|
headers: {
|
@@ -850,10 +904,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
850
904
|
end
|
851
905
|
|
852
906
|
def test_upgrade_language_model
|
853
|
-
|
907
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
854
908
|
username: "username",
|
855
909
|
password: "password"
|
856
910
|
)
|
911
|
+
service = IBMWatson::SpeechToTextV1.new(
|
912
|
+
authenticator: authenticator
|
913
|
+
)
|
857
914
|
stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/customization_id/upgrade_model")
|
858
915
|
.with(
|
859
916
|
headers: {
|
@@ -867,10 +924,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
867
924
|
end
|
868
925
|
|
869
926
|
def test_upgrade_acoustic_model
|
870
|
-
|
927
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
871
928
|
username: "username",
|
872
929
|
password: "password"
|
873
930
|
)
|
931
|
+
service = IBMWatson::SpeechToTextV1.new(
|
932
|
+
authenticator: authenticator
|
933
|
+
)
|
874
934
|
stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/acoustic_customizations/customization_id/upgrade_model")
|
875
935
|
.with(
|
876
936
|
headers: {
|
@@ -884,10 +944,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
884
944
|
end
|
885
945
|
|
886
946
|
def test_reset_acoustic_model
|
887
|
-
|
947
|
+
authenticator = IBMCloudSdkCore::BasicAuthenticator.new(
|
888
948
|
username: "username",
|
889
949
|
password: "password"
|
890
950
|
)
|
951
|
+
service = IBMWatson::SpeechToTextV1.new(
|
952
|
+
authenticator: authenticator
|
953
|
+
)
|
891
954
|
stub_request(:post, "https://stream.watsonplatform.net/speech-to-text/api/v1/acoustic_customizations/customization_id/reset")
|
892
955
|
.with(
|
893
956
|
headers: {
|