ibm_watson 2.0.0.rc1 → 2.1.1

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.
@@ -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: 2.0.0.rc1
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Nussbaum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-04 00:00:00.000000000 Z
11
+ date: 2021-06-02 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.10'
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.10'
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.1.0
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.1.0
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.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.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: '1.16'
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: '1.16'
110
+ version: '2.2'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: codecov
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -342,11 +342,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
342
342
  version: '2.3'
343
343
  required_rubygems_version: !ruby/object:Gem::Requirement
344
344
  requirements:
345
- - - ">"
345
+ - - ">="
346
346
  - !ruby/object:Gem::Version
347
- version: 1.3.1
347
+ version: '0'
348
348
  requirements: []
349
- rubygems_version: 3.0.8
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