ibm_watson 1.6.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +42 -4
- data/lib/ibm_watson/assistant_v1.rb +277 -81
- data/lib/ibm_watson/assistant_v2.rb +100 -22
- data/lib/ibm_watson/compare_comply_v1.rb +44 -23
- data/lib/ibm_watson/discovery_v1.rb +132 -14
- data/lib/ibm_watson/discovery_v2.rb +234 -18
- data/lib/ibm_watson/language_translator_v3.rb +59 -27
- data/lib/ibm_watson/natural_language_classifier_v1.rb +3 -2
- data/lib/ibm_watson/natural_language_understanding_v1.rb +705 -14
- data/lib/ibm_watson/personality_insights_v3.rb +29 -18
- data/lib/ibm_watson/speech_to_text_v1.rb +278 -121
- data/lib/ibm_watson/text_to_speech_v1.rb +689 -130
- data/lib/ibm_watson/tone_analyzer_v3.rb +11 -13
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +32 -16
- data/lib/ibm_watson/visual_recognition_v4.rb +67 -23
- data/test/integration/test_assistant_v1.rb +9 -0
- data/test/integration/test_assistant_v2.rb +9 -0
- data/test/integration/test_discovery_v2.rb +29 -0
- data/test/integration/test_natural_language_understanding_v1.rb +134 -1
- data/test/integration/test_text_to_speech_v1.rb +60 -3
- data/test/unit/test_assistant_v1.rb +52 -1
- data/test/unit/test_assistant_v2.rb +51 -0
- data/test/unit/test_discovery_v2.rb +30 -1
- data/test/unit/test_natural_language_understanding_v1.rb +231 -0
- data/test/unit/test_text_to_speech_v1.rb +152 -7
- metadata +12 -11
|
@@ -144,4 +144,235 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
|
144
144
|
)
|
|
145
145
|
assert_equal({ "deleted" => model_id }, service_response.result)
|
|
146
146
|
end
|
|
147
|
+
|
|
148
|
+
def test_sentiment_models
|
|
149
|
+
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
|
150
|
+
username: "username",
|
|
151
|
+
password: "password"
|
|
152
|
+
)
|
|
153
|
+
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
|
154
|
+
version: "2018-03-16",
|
|
155
|
+
authenticator: authenticator
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
stub_request(:post, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/sentiment?version=2018-03-16")
|
|
159
|
+
.with(
|
|
160
|
+
headers: {
|
|
161
|
+
"Accept" => "application/json",
|
|
162
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
163
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
164
|
+
}
|
|
165
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
166
|
+
training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
|
|
167
|
+
service_response = service.create_sentiment_model(
|
|
168
|
+
language: "en",
|
|
169
|
+
training_data: training_data
|
|
170
|
+
)
|
|
171
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
172
|
+
|
|
173
|
+
stub_request(:get, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/sentiment?version=2018-03-16")
|
|
174
|
+
.with(
|
|
175
|
+
headers: {
|
|
176
|
+
"Accept" => "application/json",
|
|
177
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
178
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
179
|
+
}
|
|
180
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
181
|
+
service_response = service.list_sentiment_models
|
|
182
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
183
|
+
|
|
184
|
+
stub_request(:get, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/sentiment/model_id?version=2018-03-16")
|
|
185
|
+
.with(
|
|
186
|
+
headers: {
|
|
187
|
+
"Accept" => "application/json",
|
|
188
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
189
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
190
|
+
}
|
|
191
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
192
|
+
service_response = service.get_sentiment_model(model_id: "model_id")
|
|
193
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
194
|
+
|
|
195
|
+
stub_request(:put, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/sentiment/model_id?version=2018-03-16")
|
|
196
|
+
.with(
|
|
197
|
+
headers: {
|
|
198
|
+
"Accept" => "application/json",
|
|
199
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
200
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
201
|
+
}
|
|
202
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
203
|
+
training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
|
|
204
|
+
service_response = service.update_sentiment_model(
|
|
205
|
+
model_id: "model_id",
|
|
206
|
+
language: "en",
|
|
207
|
+
training_data: training_data
|
|
208
|
+
)
|
|
209
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
210
|
+
|
|
211
|
+
stub_request(:delete, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/sentiment/model_id?version=2018-03-16")
|
|
212
|
+
.with(
|
|
213
|
+
headers: {
|
|
214
|
+
"Accept" => "application/json",
|
|
215
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
216
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
217
|
+
}
|
|
218
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
219
|
+
service_response = service.delete_sentiment_model(
|
|
220
|
+
model_id: "model_id"
|
|
221
|
+
)
|
|
222
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
def test_categories_models
|
|
226
|
+
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
|
227
|
+
username: "username",
|
|
228
|
+
password: "password"
|
|
229
|
+
)
|
|
230
|
+
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
|
231
|
+
version: "2018-03-16",
|
|
232
|
+
authenticator: authenticator
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
stub_request(:post, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/categories?version=2018-03-16")
|
|
236
|
+
.with(
|
|
237
|
+
headers: {
|
|
238
|
+
"Accept" => "application/json",
|
|
239
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
240
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
241
|
+
}
|
|
242
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
243
|
+
training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
|
|
244
|
+
service_response = service.create_categories_model(
|
|
245
|
+
language: "en",
|
|
246
|
+
training_data: training_data
|
|
247
|
+
)
|
|
248
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
249
|
+
|
|
250
|
+
stub_request(:get, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/categories?version=2018-03-16")
|
|
251
|
+
.with(
|
|
252
|
+
headers: {
|
|
253
|
+
"Accept" => "application/json",
|
|
254
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
255
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
256
|
+
}
|
|
257
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
258
|
+
service_response = service.list_categories_models
|
|
259
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
260
|
+
|
|
261
|
+
stub_request(:get, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/categories/model_id?version=2018-03-16")
|
|
262
|
+
.with(
|
|
263
|
+
headers: {
|
|
264
|
+
"Accept" => "application/json",
|
|
265
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
266
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
267
|
+
}
|
|
268
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
269
|
+
service_response = service.get_categories_model(model_id: "model_id")
|
|
270
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
271
|
+
|
|
272
|
+
stub_request(:put, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/categories/model_id?version=2018-03-16")
|
|
273
|
+
.with(
|
|
274
|
+
headers: {
|
|
275
|
+
"Accept" => "application/json",
|
|
276
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
277
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
278
|
+
}
|
|
279
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
280
|
+
training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
|
|
281
|
+
service_response = service.update_categories_model(
|
|
282
|
+
model_id: "model_id",
|
|
283
|
+
language: "en",
|
|
284
|
+
training_data: training_data
|
|
285
|
+
)
|
|
286
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
287
|
+
|
|
288
|
+
stub_request(:delete, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/categories/model_id?version=2018-03-16")
|
|
289
|
+
.with(
|
|
290
|
+
headers: {
|
|
291
|
+
"Accept" => "application/json",
|
|
292
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
293
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
294
|
+
}
|
|
295
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
296
|
+
service_response = service.delete_categories_model(
|
|
297
|
+
model_id: "model_id"
|
|
298
|
+
)
|
|
299
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
300
|
+
end
|
|
301
|
+
|
|
302
|
+
def test_classifications_models
|
|
303
|
+
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
|
304
|
+
username: "username",
|
|
305
|
+
password: "password"
|
|
306
|
+
)
|
|
307
|
+
service = IBMWatson::NaturalLanguageUnderstandingV1.new(
|
|
308
|
+
version: "2018-03-16",
|
|
309
|
+
authenticator: authenticator
|
|
310
|
+
)
|
|
311
|
+
|
|
312
|
+
stub_request(:post, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/classifications?version=2018-03-16")
|
|
313
|
+
.with(
|
|
314
|
+
headers: {
|
|
315
|
+
"Accept" => "application/json",
|
|
316
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
317
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
318
|
+
}
|
|
319
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
320
|
+
training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
|
|
321
|
+
service_response = service.create_classifications_model(
|
|
322
|
+
language: "en",
|
|
323
|
+
training_data: training_data
|
|
324
|
+
)
|
|
325
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
326
|
+
|
|
327
|
+
stub_request(:get, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/classifications?version=2018-03-16")
|
|
328
|
+
.with(
|
|
329
|
+
headers: {
|
|
330
|
+
"Accept" => "application/json",
|
|
331
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
332
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
333
|
+
}
|
|
334
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
335
|
+
service_response = service.list_classifications_models
|
|
336
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
337
|
+
|
|
338
|
+
stub_request(:get, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/classifications/model_id?version=2018-03-16")
|
|
339
|
+
.with(
|
|
340
|
+
headers: {
|
|
341
|
+
"Accept" => "application/json",
|
|
342
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
343
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
344
|
+
}
|
|
345
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
346
|
+
service_response = service.get_classifications_model(model_id: "model_id")
|
|
347
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
348
|
+
|
|
349
|
+
stub_request(:put, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/classifications/model_id?version=2018-03-16")
|
|
350
|
+
.with(
|
|
351
|
+
headers: {
|
|
352
|
+
"Accept" => "application/json",
|
|
353
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
354
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
355
|
+
}
|
|
356
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
357
|
+
training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
|
|
358
|
+
service_response = service.update_classifications_model(
|
|
359
|
+
model_id: "model_id",
|
|
360
|
+
language: "en",
|
|
361
|
+
training_data: training_data
|
|
362
|
+
)
|
|
363
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
364
|
+
|
|
365
|
+
stub_request(:delete, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/classifications/model_id?version=2018-03-16")
|
|
366
|
+
.with(
|
|
367
|
+
headers: {
|
|
368
|
+
"Accept" => "application/json",
|
|
369
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
370
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
|
371
|
+
}
|
|
372
|
+
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
|
373
|
+
service_response = service.delete_classifications_model(
|
|
374
|
+
model_id: "model_id"
|
|
375
|
+
)
|
|
376
|
+
assert_equal({ "resulting_key" => true }, service_response.result)
|
|
377
|
+
end
|
|
147
378
|
end
|
|
@@ -151,7 +151,7 @@ class TextToSpeechV1Test < Minitest::Test
|
|
|
151
151
|
assert_equal(response, service_response.result)
|
|
152
152
|
end
|
|
153
153
|
|
|
154
|
-
def
|
|
154
|
+
def test_custom_custom_models
|
|
155
155
|
response = { "customizations" => "yep" }
|
|
156
156
|
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
|
157
157
|
username: "username",
|
|
@@ -170,7 +170,7 @@ class TextToSpeechV1Test < Minitest::Test
|
|
|
170
170
|
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
171
171
|
}
|
|
172
172
|
).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
|
|
173
|
-
service_response = service.
|
|
173
|
+
service_response = service.list_custom_models
|
|
174
174
|
assert_equal(response, service_response.result)
|
|
175
175
|
|
|
176
176
|
stub_request(:get, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/customizations?language=en-US")
|
|
@@ -181,7 +181,7 @@ class TextToSpeechV1Test < Minitest::Test
|
|
|
181
181
|
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
182
182
|
}
|
|
183
183
|
).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
|
|
184
|
-
service_response = service.
|
|
184
|
+
service_response = service.list_custom_models(
|
|
185
185
|
language: "en-US"
|
|
186
186
|
)
|
|
187
187
|
assert_equal(response, service_response.result)
|
|
@@ -196,7 +196,7 @@ class TextToSpeechV1Test < Minitest::Test
|
|
|
196
196
|
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
197
197
|
}
|
|
198
198
|
).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
|
|
199
|
-
service_response = service.
|
|
199
|
+
service_response = service.create_custom_model(
|
|
200
200
|
name: "name",
|
|
201
201
|
description: "description"
|
|
202
202
|
)
|
|
@@ -210,7 +210,7 @@ class TextToSpeechV1Test < Minitest::Test
|
|
|
210
210
|
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
211
211
|
}
|
|
212
212
|
).to_return(status: 200, body: { "customization" => "yep, just one" }.to_json, headers: { "Content-Type" => "application/json" })
|
|
213
|
-
service_response = service.
|
|
213
|
+
service_response = service.get_custom_model(
|
|
214
214
|
customization_id: "custid"
|
|
215
215
|
)
|
|
216
216
|
assert_equal({ "customization" => "yep, just one" }, service_response.result)
|
|
@@ -225,7 +225,7 @@ class TextToSpeechV1Test < Minitest::Test
|
|
|
225
225
|
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
226
226
|
}
|
|
227
227
|
).to_return(status: 200, body: "", headers: {})
|
|
228
|
-
service_response = service.
|
|
228
|
+
service_response = service.update_custom_model(
|
|
229
229
|
customization_id: "custid",
|
|
230
230
|
name: "name",
|
|
231
231
|
description: "description"
|
|
@@ -239,7 +239,7 @@ class TextToSpeechV1Test < Minitest::Test
|
|
|
239
239
|
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
240
240
|
}
|
|
241
241
|
).to_return(status: 200, body: "", headers: {})
|
|
242
|
-
service_response = service.
|
|
242
|
+
service_response = service.delete_custom_model(
|
|
243
243
|
customization_id: "custid"
|
|
244
244
|
)
|
|
245
245
|
assert(service_response.nil?)
|
|
@@ -354,4 +354,149 @@ class TextToSpeechV1Test < Minitest::Test
|
|
|
354
354
|
)
|
|
355
355
|
assert(service_response.nil?)
|
|
356
356
|
end
|
|
357
|
+
|
|
358
|
+
def test_custom_prompts
|
|
359
|
+
response = {
|
|
360
|
+
"prompt" => "Thank you and good-bye!",
|
|
361
|
+
"prompt_id" => "goodbye"
|
|
362
|
+
}
|
|
363
|
+
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
|
364
|
+
username: "username",
|
|
365
|
+
password: "password"
|
|
366
|
+
)
|
|
367
|
+
service = IBMWatson::TextToSpeechV1.new(
|
|
368
|
+
username: "username",
|
|
369
|
+
password: "password",
|
|
370
|
+
authenticator: authenticator
|
|
371
|
+
)
|
|
372
|
+
stub_request(:get, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/customizations/cust_id/prompts")
|
|
373
|
+
.with(
|
|
374
|
+
headers: {
|
|
375
|
+
"Accept" => "application/json",
|
|
376
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
377
|
+
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
378
|
+
}
|
|
379
|
+
).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
|
|
380
|
+
service_response = service.list_custom_prompts(
|
|
381
|
+
customization_id: "cust_id"
|
|
382
|
+
)
|
|
383
|
+
assert_equal(response, service_response.result)
|
|
384
|
+
|
|
385
|
+
stub_request(:get, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/customizations/cust_id/prompts/p_id")
|
|
386
|
+
.with(
|
|
387
|
+
headers: {
|
|
388
|
+
"Accept" => "application/json",
|
|
389
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
390
|
+
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
391
|
+
}
|
|
392
|
+
).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
|
|
393
|
+
service_response = service.get_custom_prompt(
|
|
394
|
+
customization_id: "cust_id",
|
|
395
|
+
prompt_id: "p_id"
|
|
396
|
+
)
|
|
397
|
+
assert_equal(response, service_response.result)
|
|
398
|
+
|
|
399
|
+
stub_request(:delete, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/customizations/cust_id/prompts/p_id")
|
|
400
|
+
.with(
|
|
401
|
+
headers: {
|
|
402
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
403
|
+
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
404
|
+
}
|
|
405
|
+
).to_return(status: 200, body: "", headers: {})
|
|
406
|
+
service_response = service.delete_custom_prompt(
|
|
407
|
+
customization_id: "cust_id",
|
|
408
|
+
prompt_id: "p_id"
|
|
409
|
+
)
|
|
410
|
+
assert(service_response.nil?)
|
|
411
|
+
|
|
412
|
+
stub_request(:post, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/customizations/cust_id/prompts/p_id")
|
|
413
|
+
.with(
|
|
414
|
+
headers: {
|
|
415
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
416
|
+
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
417
|
+
}
|
|
418
|
+
).to_return(status: 200, headers: { "Content-Type" => "application/json" })
|
|
419
|
+
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
|
420
|
+
service_response = service.add_custom_prompt(
|
|
421
|
+
customization_id: "cust_id",
|
|
422
|
+
prompt_id: "p_id",
|
|
423
|
+
metadata: { "prompt_text" => "Thank you and good-bye!" },
|
|
424
|
+
file: audio_file
|
|
425
|
+
)
|
|
426
|
+
assert_equal(200, service_response.status)
|
|
427
|
+
end
|
|
428
|
+
|
|
429
|
+
def test_speaker_models
|
|
430
|
+
response = {
|
|
431
|
+
"speakers" => [
|
|
432
|
+
{
|
|
433
|
+
"speaker_id" => "56367f89-546d-4b37-891e-4eb0c13cc833",
|
|
434
|
+
"name" => "speaker_one"
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
"speaker_id" => "323e4476-63de-9825-7cd7-8120e45f8331",
|
|
438
|
+
"name" => "speaker_two"
|
|
439
|
+
}
|
|
440
|
+
]
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
|
444
|
+
username: "username",
|
|
445
|
+
password: "password"
|
|
446
|
+
)
|
|
447
|
+
service = IBMWatson::TextToSpeechV1.new(
|
|
448
|
+
username: "username",
|
|
449
|
+
password: "password",
|
|
450
|
+
authenticator: authenticator
|
|
451
|
+
)
|
|
452
|
+
stub_request(:get, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/speakers")
|
|
453
|
+
.with(
|
|
454
|
+
headers: {
|
|
455
|
+
"Accept" => "application/json",
|
|
456
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
457
|
+
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
458
|
+
}
|
|
459
|
+
).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
|
|
460
|
+
service_response = service.list_speaker_models
|
|
461
|
+
assert_equal(response, service_response.result)
|
|
462
|
+
|
|
463
|
+
stub_request(:get, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/speakers/speaker_id1")
|
|
464
|
+
.with(
|
|
465
|
+
headers: {
|
|
466
|
+
"Accept" => "application/json",
|
|
467
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
468
|
+
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
469
|
+
}
|
|
470
|
+
).to_return(status: 200, body: response.to_json, headers: { "Content-Type" => "application/json" })
|
|
471
|
+
service_response = service.get_speaker_model(
|
|
472
|
+
speaker_id: "speaker_id1"
|
|
473
|
+
)
|
|
474
|
+
assert_equal(response, service_response.result)
|
|
475
|
+
|
|
476
|
+
stub_request(:delete, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/speakers/speaker_id1")
|
|
477
|
+
.with(
|
|
478
|
+
headers: {
|
|
479
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
480
|
+
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
481
|
+
}
|
|
482
|
+
).to_return(status: 200, body: "", headers: {})
|
|
483
|
+
service_response = service.delete_speaker_model(
|
|
484
|
+
speaker_id: "speaker_id1"
|
|
485
|
+
)
|
|
486
|
+
assert(service_response.nil?)
|
|
487
|
+
|
|
488
|
+
stub_request(:post, "https://api.us-south.text-to-speech.watson.cloud.ibm.com/v1/speakers?speaker_name=Russ")
|
|
489
|
+
.with(
|
|
490
|
+
headers: {
|
|
491
|
+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
|
492
|
+
"Host" => "api.us-south.text-to-speech.watson.cloud.ibm.com"
|
|
493
|
+
}
|
|
494
|
+
).to_return(status: 200, body: "", headers: {})
|
|
495
|
+
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
|
496
|
+
service_response = service.create_speaker_model(
|
|
497
|
+
speaker_name: "Russ",
|
|
498
|
+
audio: audio_file
|
|
499
|
+
)
|
|
500
|
+
assert_equal(200, service_response.status)
|
|
501
|
+
end
|
|
357
502
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ibm_watson
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Max Nussbaum
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2021-05-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: concurrent-ruby
|
|
@@ -44,42 +44,42 @@ dependencies:
|
|
|
44
44
|
requirements:
|
|
45
45
|
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0.
|
|
47
|
+
version: '0.11'
|
|
48
48
|
type: :runtime
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
52
|
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0.
|
|
54
|
+
version: '0.11'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
56
|
name: http
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 4.
|
|
61
|
+
version: 4.4.0
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 4.
|
|
68
|
+
version: 4.4.0
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: ibm_cloud_sdk_core
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
73
|
- - "~>"
|
|
74
74
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: 1.1.
|
|
75
|
+
version: 1.1.3
|
|
76
76
|
type: :runtime
|
|
77
77
|
prerelease: false
|
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
79
|
requirements:
|
|
80
80
|
- - "~>"
|
|
81
81
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: 1.1.
|
|
82
|
+
version: 1.1.3
|
|
83
83
|
- !ruby/object:Gem::Dependency
|
|
84
84
|
name: jwt
|
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -100,14 +100,14 @@ dependencies:
|
|
|
100
100
|
requirements:
|
|
101
101
|
- - "~>"
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version: '
|
|
103
|
+
version: '2.2'
|
|
104
104
|
type: :development
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - "~>"
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version: '
|
|
110
|
+
version: '2.2'
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
112
|
name: codecov
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -346,7 +346,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
346
346
|
- !ruby/object:Gem::Version
|
|
347
347
|
version: '0'
|
|
348
348
|
requirements: []
|
|
349
|
-
|
|
349
|
+
rubyforge_project:
|
|
350
|
+
rubygems_version: 2.7.6.3
|
|
350
351
|
signing_key:
|
|
351
352
|
specification_version: 4
|
|
352
353
|
summary: Official client library to use the IBM Watson Services
|