ibm_watson 1.2.0 → 1.6.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 +33 -5
- data/lib/ibm_watson/assistant_v1.rb +153 -209
- data/lib/ibm_watson/assistant_v2.rb +168 -15
- data/lib/ibm_watson/compare_comply_v1.rb +11 -5
- data/lib/ibm_watson/discovery_v1.rb +14 -8
- data/lib/ibm_watson/discovery_v2.rb +605 -12
- data/lib/ibm_watson/language_translator_v3.rb +166 -47
- data/lib/ibm_watson/natural_language_classifier_v1.rb +10 -4
- data/lib/ibm_watson/natural_language_understanding_v1.rb +19 -15
- data/lib/ibm_watson/personality_insights_v3.rb +17 -11
- data/lib/ibm_watson/speech_to_text_v1.rb +323 -195
- data/lib/ibm_watson/text_to_speech_v1.rb +75 -59
- data/lib/ibm_watson/tone_analyzer_v3.rb +11 -5
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +11 -5
- data/lib/ibm_watson/visual_recognition_v4.rb +199 -4
- data/test/integration/test_assistant_v2.rb +25 -0
- data/test/integration/test_compare_comply_v1.rb +1 -12
- data/test/integration/test_discovery_v2.rb +118 -6
- data/test/integration/test_language_translator_v3.rb +5 -0
- data/test/integration/test_speech_to_text_v1.rb +2 -0
- data/test/integration/test_visual_recognition_v4.rb +9 -0
- data/test/unit/test_assistant_v1.rb +98 -98
- data/test/unit/test_assistant_v2.rb +102 -8
- data/test/unit/test_compare_comply_v1.rb +20 -20
- data/test/unit/test_discovery_v1.rb +125 -125
- data/test/unit/test_discovery_v2.rb +262 -29
- data/test/unit/test_language_translator_v3.rb +85 -24
- data/test/unit/test_natural_language_classifier_v1.rb +17 -17
- data/test/unit/test_natural_language_understanding_v1.rb +10 -10
- data/test/unit/test_personality_insights_v3.rb +14 -10
- data/test/unit/test_speech_to_text_v1.rb +97 -97
- data/test/unit/test_text_to_speech_v1.rb +41 -41
- data/test/unit/test_tone_analyzer_v3.rb +12 -12
- data/test/unit/test_visual_recognition_v3.rb +16 -16
- data/test/unit/test_visual_recognition_v4.rb +117 -30
- metadata +5 -6
- data/test/unit/test_vcap_using_personality_insights.rb +0 -161
@@ -19,34 +19,34 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
19
19
|
list_response = {
|
20
20
|
"classifiers" => [
|
21
21
|
{
|
22
|
-
"url" => "https://
|
22
|
+
"url" => "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/natural-language-classifier-experimental/api/v1/classifiers/497EF2-nlc-00",
|
23
23
|
"classifier_id" => "497EF2-nlc-00"
|
24
24
|
}
|
25
25
|
]
|
26
26
|
}
|
27
|
-
stub_request(:get, "https://
|
27
|
+
stub_request(:get, "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers")
|
28
28
|
.with(
|
29
29
|
headers: {
|
30
30
|
"Accept" => "application/json",
|
31
31
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
32
|
-
"Host" => "
|
32
|
+
"Host" => "api.us-south.natural-language-classifier.watson.cloud.ibm.com"
|
33
33
|
}
|
34
34
|
).to_return(status: 200, body: list_response.to_json, headers: { "Content-Type" => "application/json" })
|
35
35
|
service_response = service.list_classifiers
|
36
36
|
assert_equal(list_response, service_response.result)
|
37
37
|
|
38
38
|
status_response = {
|
39
|
-
"url" => "https://
|
39
|
+
"url" => "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers/497EF2-nlc-00",
|
40
40
|
"status" => "Available",
|
41
41
|
"status_description" => "The classifier instance is now available and is ready to take classifier requests.",
|
42
42
|
"classifier_id" => "497EF2-nlc-00"
|
43
43
|
}
|
44
|
-
stub_request(:get, "https://
|
44
|
+
stub_request(:get, "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers/497EF2-nlc-00")
|
45
45
|
.with(
|
46
46
|
headers: {
|
47
47
|
"Accept" => "application/json",
|
48
48
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
49
|
-
"Host" => "
|
49
|
+
"Host" => "api.us-south.natural-language-classifier.watson.cloud.ibm.com"
|
50
50
|
}
|
51
51
|
).to_return(status: 200, body: status_response.to_json, headers: { "Content-Type" => "application/json" })
|
52
52
|
service_response = service.get_classifier(
|
@@ -55,7 +55,7 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
55
55
|
assert_equal(status_response, service_response.result)
|
56
56
|
|
57
57
|
classify_response = {
|
58
|
-
"url" => "https://
|
58
|
+
"url" => "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1",
|
59
59
|
"text" => "test",
|
60
60
|
"classes" =>
|
61
61
|
[
|
@@ -71,14 +71,14 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
71
71
|
"classifier_id" => "497EF2-nlc-00",
|
72
72
|
"top_class" => "conditions"
|
73
73
|
}
|
74
|
-
stub_request(:post, "https://
|
74
|
+
stub_request(:post, "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers/497EF2-nlc-00/classify")
|
75
75
|
.with(
|
76
76
|
body: "{\"text\":\"test\"}",
|
77
77
|
headers: {
|
78
78
|
"Accept" => "application/json",
|
79
79
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
80
80
|
"Content-Type" => "application/json",
|
81
|
-
"Host" => "
|
81
|
+
"Host" => "api.us-south.natural-language-classifier.watson.cloud.ibm.com"
|
82
82
|
}
|
83
83
|
).to_return(status: 200, body: classify_response.to_json, headers: { "Content-Type" => "application/json" })
|
84
84
|
service_response = service.classify(
|
@@ -88,17 +88,17 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
88
88
|
assert_equal(classify_response, service_response.result)
|
89
89
|
|
90
90
|
create_response = {
|
91
|
-
"url" => "https://
|
91
|
+
"url" => "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers/497EF2-nlc-00",
|
92
92
|
"status" => "Available",
|
93
93
|
"status_description" => "The classifier instance is now available and is ready to take classifier requests.",
|
94
94
|
"classifier_id" => "497EF2-nlc-00"
|
95
95
|
}
|
96
|
-
stub_request(:post, "https://
|
96
|
+
stub_request(:post, "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers")
|
97
97
|
.with(
|
98
98
|
headers: {
|
99
99
|
"Accept" => "application/json",
|
100
100
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
101
|
-
"Host" => "
|
101
|
+
"Host" => "api.us-south.natural-language-classifier.watson.cloud.ibm.com"
|
102
102
|
}
|
103
103
|
).to_return(status: 200, body: create_response.to_json, headers: { "Content-Type" => "application/json" })
|
104
104
|
training_data = File.open(Dir.getwd + "/resources/weather_data_train.csv")
|
@@ -114,12 +114,12 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
114
114
|
)
|
115
115
|
assert_equal(create_response, service_response.result)
|
116
116
|
|
117
|
-
stub_request(:delete, "https://
|
117
|
+
stub_request(:delete, "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers/497EF2-nlc-00")
|
118
118
|
.with(
|
119
119
|
headers: {
|
120
120
|
"Accept" => "application/json",
|
121
121
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
122
|
-
"Host" => "
|
122
|
+
"Host" => "api.us-south.natural-language-classifier.watson.cloud.ibm.com"
|
123
123
|
}
|
124
124
|
).to_return(status: 200, body: "", headers: {})
|
125
125
|
service_response = service.delete_classifier(
|
@@ -138,7 +138,7 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
138
138
|
)
|
139
139
|
classify_collection_response = {
|
140
140
|
"classifier_id" => "497EF2-nlc-00",
|
141
|
-
"url" => "https://
|
141
|
+
"url" => "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers/10D41B-nlc-1",
|
142
142
|
"collection" => [
|
143
143
|
{
|
144
144
|
"text" => "How hot will it be today?",
|
@@ -172,14 +172,14 @@ class NaturalLanguageClassifierV1Test < Minitest::Test
|
|
172
172
|
}
|
173
173
|
classifier_id = "497EF2-nlc-00"
|
174
174
|
collection = [{ "text" => "How hot will it be today?" }, { "text" => "Is it hot outside?" }]
|
175
|
-
stub_request(:post, "https://
|
175
|
+
stub_request(:post, "https://api.us-south.natural-language-classifier.watson.cloud.ibm.com/v1/classifiers/497EF2-nlc-00/classify_collection")
|
176
176
|
.with(
|
177
177
|
body: "{\"collection\":[{\"text\":\"How hot will it be today?\"},{\"text\":\"Is it hot outside?\"}]}",
|
178
178
|
headers: {
|
179
179
|
"Accept" => "application/json",
|
180
180
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
181
181
|
"Content-Type" => "application/json",
|
182
|
-
"Host" => "
|
182
|
+
"Host" => "api.us-south.natural-language-classifier.watson.cloud.ibm.com"
|
183
183
|
}
|
184
184
|
).to_return(status: 200, body: classify_collection_response.to_json, headers: { "Content-Type" => "application/json" })
|
185
185
|
service_response = service.classify_collection(
|
@@ -17,14 +17,14 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
17
17
|
version: "2018-03-16",
|
18
18
|
authenticator: authenticator
|
19
19
|
)
|
20
|
-
stub_request(:post, "https://
|
20
|
+
stub_request(:post, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/analyze?version=2018-03-16")
|
21
21
|
.with(
|
22
22
|
body: "{\"features\":{\"sentiment\":{}},\"text\":\"hello this is a test\"}",
|
23
23
|
headers: {
|
24
24
|
"Accept" => "application/json",
|
25
25
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
26
26
|
"Content-Type" => "application/json",
|
27
|
-
"Host" => "
|
27
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
28
28
|
}
|
29
29
|
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
30
30
|
service_response = service.analyze(
|
@@ -45,14 +45,14 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
45
45
|
version: "2018-03-16",
|
46
46
|
authenticator: authenticator
|
47
47
|
)
|
48
|
-
stub_request(:post, "https://
|
48
|
+
stub_request(:post, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/analyze?version=2018-03-16")
|
49
49
|
.with(
|
50
50
|
body: "{\"features\":{\"sentiment\":{},\"emotion\":{\"document\":false}},\"html\":\"<span>hello this is a test </span>\"}",
|
51
51
|
headers: {
|
52
52
|
"Accept" => "application/json",
|
53
53
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
54
54
|
"Content-Type" => "application/json",
|
55
|
-
"Host" => "
|
55
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
56
56
|
}
|
57
57
|
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
58
58
|
service_response = service.analyze(
|
@@ -76,14 +76,14 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
76
76
|
version: "2018-03-16",
|
77
77
|
authenticator: authenticator
|
78
78
|
)
|
79
|
-
stub_request(:post, "https://
|
79
|
+
stub_request(:post, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/analyze?version=2018-03-16")
|
80
80
|
.with(
|
81
81
|
body: "{\"features\":{\"sentiment\":{},\"emotion\":{\"document\":false}},\"url\":\"http://cnn.com\",\"xpath\":\"/bogus/xpath\",\"language\":\"en\"}",
|
82
82
|
headers: {
|
83
83
|
"Accept" => "application/json",
|
84
84
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
85
85
|
"Content-Type" => "application/json",
|
86
|
-
"Host" => "
|
86
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
87
87
|
}
|
88
88
|
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
89
89
|
service_response = service.analyze(
|
@@ -109,12 +109,12 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
109
109
|
version: "2018-03-16",
|
110
110
|
authenticator: authenticator
|
111
111
|
)
|
112
|
-
stub_request(:get, "https://
|
112
|
+
stub_request(:get, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models?version=2018-03-16")
|
113
113
|
.with(
|
114
114
|
headers: {
|
115
115
|
"Accept" => "application/json",
|
116
116
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
117
|
-
"Host" => "
|
117
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
118
118
|
}
|
119
119
|
).to_return(status: 200, body: { resulting_key: true }.to_json, headers: { "Content-Type" => "application/json" })
|
120
120
|
service_response = service.list_models
|
@@ -131,12 +131,12 @@ class NaturalLanguageUnderstandingV1Test < Minitest::Test
|
|
131
131
|
version: "2018-03-16",
|
132
132
|
authenticator: authenticator
|
133
133
|
)
|
134
|
-
stub_request(:delete, "https://
|
134
|
+
stub_request(:delete, "https://api.us-south.natural-language-understanding.watson.cloud.ibm.com/v1/models/invalid_model_id?version=2018-03-16")
|
135
135
|
.with(
|
136
136
|
headers: {
|
137
137
|
"Accept" => "application/json",
|
138
138
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
139
|
-
"Host" => "
|
139
|
+
"Host" => "api.us-south.natural-language-understanding.watson.cloud.ibm.com"
|
140
140
|
}
|
141
141
|
).to_return(status: 200, body: { deleted: model_id }.to_json, headers: { "Content-Type" => "application/json" })
|
142
142
|
service_response = service.delete_model(
|
@@ -15,14 +15,14 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
15
15
|
"Content-Type" => "application/json"
|
16
16
|
}
|
17
17
|
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: JSON.parse(profile_response), headers: headers)
|
18
|
-
stub_request(:post, "https://
|
18
|
+
stub_request(:post, "https://api.us-south.personality-insights.watson.cloud.ibm.com/v3/profile?version=2017-10-13")
|
19
19
|
.with(
|
20
20
|
body: personality_text,
|
21
21
|
headers: {
|
22
22
|
"Accept" => "application/json",
|
23
23
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
24
24
|
"Content-Type" => "text/plain;charset=utf-8",
|
25
|
-
"Host" => "
|
25
|
+
"Host" => "api.us-south.personality-insights.watson.cloud.ibm.com"
|
26
26
|
}
|
27
27
|
).to_return(status: 200, body: profile_response, headers: headers)
|
28
28
|
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
@@ -33,6 +33,7 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
33
33
|
version: "2017-10-13",
|
34
34
|
authenticator: authenticator
|
35
35
|
)
|
36
|
+
service.service_url = "https://api.us-south.personality-insights.watson.cloud.ibm.com"
|
36
37
|
service_response = service.profile(
|
37
38
|
accept: "application/json",
|
38
39
|
content: personality_text,
|
@@ -45,14 +46,14 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
45
46
|
assert(expected_response.headers[key] == service_response.headers[key])
|
46
47
|
end
|
47
48
|
|
48
|
-
stub_request(:post, "https://
|
49
|
+
stub_request(:post, "https://api.us-south.personality-insights.watson.cloud.ibm.com/v3/profile?version=2017-10-13")
|
49
50
|
.with(
|
50
51
|
body: { "personality" => "text" }.to_json,
|
51
52
|
headers: {
|
52
53
|
"Accept" => "application/json",
|
53
54
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
54
55
|
"Content-Type" => "application/json",
|
55
|
-
"Host" => "
|
56
|
+
"Host" => "api.us-south.personality-insights.watson.cloud.ibm.com"
|
56
57
|
}
|
57
58
|
).to_return(status: 200, body: { "profile" => "response" }.to_json, headers: headers)
|
58
59
|
service_response = service.profile(
|
@@ -70,14 +71,14 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
70
71
|
"Content-Type" => "application/json"
|
71
72
|
}
|
72
73
|
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: JSON.parse(profile_response), headers: headers)
|
73
|
-
stub_request(:post, "https://
|
74
|
+
stub_request(:post, "https://api.us-south.personality-insights.watson.cloud.ibm.com/v3/profile?consumption_preferences=true&raw_scores=true&version=2017-10-13")
|
74
75
|
.with(
|
75
76
|
body: personality_text,
|
76
77
|
headers: {
|
77
78
|
"Accept" => "application/json",
|
78
79
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
79
80
|
"Content-Type" => "application/json",
|
80
|
-
"Host" => "
|
81
|
+
"Host" => "api.us-south.personality-insights.watson.cloud.ibm.com"
|
81
82
|
}
|
82
83
|
).to_return(status: 200, body: profile_response, headers: headers)
|
83
84
|
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
@@ -88,6 +89,7 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
88
89
|
version: "2017-10-13",
|
89
90
|
authenticator: authenticator
|
90
91
|
)
|
92
|
+
service.service_url = "https://api.us-south.personality-insights.watson.cloud.ibm.com"
|
91
93
|
service_response = service.profile(
|
92
94
|
accept: "application/json",
|
93
95
|
content: personality_text,
|
@@ -110,14 +112,14 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
110
112
|
"Content-Type" => "text/csv"
|
111
113
|
}
|
112
114
|
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
|
113
|
-
stub_request(:post, "https://
|
115
|
+
stub_request(:post, "https://api.us-south.personality-insights.watson.cloud.ibm.com/v3/profile?consumption_preferences=true&csv_headers=true&raw_scores=true&version=2017-10-13")
|
114
116
|
.with(
|
115
117
|
body: personality_text,
|
116
118
|
headers: {
|
117
119
|
"Accept" => "text/csv",
|
118
120
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
119
121
|
"Content-Type" => "application/json",
|
120
|
-
"Host" => "
|
122
|
+
"Host" => "api.us-south.personality-insights.watson.cloud.ibm.com"
|
121
123
|
}
|
122
124
|
).to_return(status: 200, body: profile_response, headers: headers)
|
123
125
|
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
@@ -128,6 +130,7 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
128
130
|
version: "2017-10-13",
|
129
131
|
authenticator: authenticator
|
130
132
|
)
|
133
|
+
service.service_url = "https://api.us-south.personality-insights.watson.cloud.ibm.com"
|
131
134
|
service_response = service.profile(
|
132
135
|
content: personality_text,
|
133
136
|
content_type: "application/json",
|
@@ -151,7 +154,7 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
151
154
|
"Content-Type" => "application/json"
|
152
155
|
}
|
153
156
|
expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
|
154
|
-
stub_request(:post, "https://
|
157
|
+
stub_request(:post, "https://api.us-south.personality-insights.watson.cloud.ibm.com/v3/profile?version=2017-10-13")
|
155
158
|
.with(
|
156
159
|
body: personality_text,
|
157
160
|
headers: {
|
@@ -160,7 +163,7 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
160
163
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
161
164
|
"Content-Language" => "es",
|
162
165
|
"Content-Type" => "text/plain;charset=utf-8",
|
163
|
-
"Host" => "
|
166
|
+
"Host" => "api.us-south.personality-insights.watson.cloud.ibm.com"
|
164
167
|
}
|
165
168
|
).to_return(status: 200, body: profile_response.to_json, headers: headers)
|
166
169
|
authenticator = IBMWatson::Authenticators::BasicAuthenticator.new(
|
@@ -171,6 +174,7 @@ class PersonalityInsightsV3Test < Minitest::Test
|
|
171
174
|
version: "2017-10-13",
|
172
175
|
authenticator: authenticator
|
173
176
|
)
|
177
|
+
service.service_url = "https://api.us-south.personality-insights.watson.cloud.ibm.com"
|
174
178
|
service_response = service.profile(
|
175
179
|
accept: "application/json",
|
176
180
|
content: personality_text,
|
@@ -28,7 +28,7 @@ class SpeechToTextV1Test < Minitest::Test
|
|
28
28
|
models_response = {
|
29
29
|
"models" => [
|
30
30
|
{
|
31
|
-
"url" => "https://
|
31
|
+
"url" => "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/models/WatsonModel",
|
32
32
|
"rate" => 16_000,
|
33
33
|
"name" => "WatsonModel",
|
34
34
|
"language" => "en-US",
|
@@ -43,12 +43,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
43
43
|
service = IBMWatson::SpeechToTextV1.new(
|
44
44
|
authenticator: authenticator
|
45
45
|
)
|
46
|
-
stub_request(:get, "https://
|
46
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/models")
|
47
47
|
.with(
|
48
48
|
headers: {
|
49
49
|
"Accept" => "application/json",
|
50
50
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
51
|
-
"Host" => "
|
51
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
52
52
|
}
|
53
53
|
).to_return(status: 200, body: models_response.to_json, headers: { "Content-Type" => "application/json" })
|
54
54
|
service_response = service.list_models
|
@@ -68,13 +68,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
68
68
|
"result_index" => 0
|
69
69
|
}
|
70
70
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
71
|
-
stub_request(:post, "https://
|
71
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognize")
|
72
72
|
.with(
|
73
73
|
headers: {
|
74
74
|
"Accept" => "application/json",
|
75
75
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
76
76
|
"Content-Type" => "audio/l16; rate=44100",
|
77
|
-
"Host" => "
|
77
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
78
78
|
}
|
79
79
|
).to_return(status: 200, body: recognize_response.to_json, headers: { "Content-Type" => "application/json" })
|
80
80
|
service_response = service.recognize(
|
@@ -102,13 +102,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
102
102
|
)
|
103
103
|
|
104
104
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
105
|
-
stub_request(:post, "ws://
|
105
|
+
stub_request(:post, "ws://api.us-south.speech-to-text.watson.cloud.ibm.com/speech-to-text/api/v1/recognize")
|
106
106
|
.with(
|
107
107
|
headers: {
|
108
108
|
"Accept" => "application/json",
|
109
109
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
110
110
|
"Content-Type" => "audio/l16; rate=44100",
|
111
|
-
"Host" => "
|
111
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
112
112
|
}
|
113
113
|
).to_return(status: 200, body: "", headers: { "Content-Type" => "application/json" })
|
114
114
|
|
@@ -134,12 +134,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
134
134
|
service = IBMWatson::SpeechToTextV1.new(
|
135
135
|
authenticator: authenticator
|
136
136
|
)
|
137
|
-
stub_request(:get, "https://
|
137
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/models/modelid")
|
138
138
|
.with(
|
139
139
|
headers: {
|
140
140
|
"Accept" => "application/json",
|
141
141
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
142
|
-
"Host" => "
|
142
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
143
143
|
}
|
144
144
|
).to_return(status: 200, body: { "bogus_response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
145
145
|
service_response = service.get_model(
|
@@ -166,23 +166,23 @@ class SpeechToTextV1Test < Minitest::Test
|
|
166
166
|
service = IBMWatson::SpeechToTextV1.new(
|
167
167
|
authenticator: authenticator
|
168
168
|
)
|
169
|
-
stub_request(:get, "https://
|
169
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognitions")
|
170
170
|
.with(
|
171
171
|
headers: {
|
172
172
|
"Accept" => "application/json",
|
173
173
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
174
|
-
"Host" => "
|
174
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
175
175
|
}
|
176
176
|
).to_return(status: 200, body: get_response.to_json, headers: { "Content-Type" => "application/json" })
|
177
177
|
service_response = service.check_jobs
|
178
178
|
assert_equal("6193190c-0777-11e8-9b4b-43ad845196dd", service_response.result["recognitions"][0]["id"])
|
179
179
|
|
180
|
-
stub_request(:get, "https://
|
180
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognitions/jobid")
|
181
181
|
.with(
|
182
182
|
headers: {
|
183
183
|
"Accept" => "application/json",
|
184
184
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
185
|
-
"Host" => "
|
185
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
186
186
|
}
|
187
187
|
).to_return(status: 200, body: { "status" => "waiting" }.to_json, headers: { "Content-Type" => "application/json" })
|
188
188
|
service_response = service.check_job(
|
@@ -190,13 +190,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
190
190
|
)
|
191
191
|
assert_equal({ "status" => "waiting" }, service_response.result)
|
192
192
|
|
193
|
-
stub_request(:post, "https://
|
193
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognitions")
|
194
194
|
.with(
|
195
195
|
headers: {
|
196
196
|
"Accept" => "application/json",
|
197
197
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
198
198
|
"Content-Type" => "audio/basic",
|
199
|
-
"Host" => "
|
199
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
200
200
|
}
|
201
201
|
).to_return(status: 200, body: { "status" => "waiting" }.to_json, headers: { "Content-Type" => "application/json" })
|
202
202
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
@@ -206,11 +206,11 @@ class SpeechToTextV1Test < Minitest::Test
|
|
206
206
|
)
|
207
207
|
assert_equal({ "status" => "waiting" }, service_response.result)
|
208
208
|
|
209
|
-
stub_request(:delete, "https://
|
209
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognitions/jobid")
|
210
210
|
.with(
|
211
211
|
headers: {
|
212
212
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
213
|
-
"Host" => "
|
213
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
214
214
|
}
|
215
215
|
).to_return(status: 200, body: { "description" => "deleted successfully" }.to_json, headers: { "Content-Type" => "application/json" })
|
216
216
|
service_response = service.delete_job(
|
@@ -227,11 +227,11 @@ class SpeechToTextV1Test < Minitest::Test
|
|
227
227
|
service = IBMWatson::SpeechToTextV1.new(
|
228
228
|
authenticator: authenticator
|
229
229
|
)
|
230
|
-
stub_request(:post, "https://
|
230
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/register_callback?callback_url=monitorcalls.com")
|
231
231
|
.with(
|
232
232
|
headers: {
|
233
233
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
234
|
-
"Host" => "
|
234
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
235
235
|
}
|
236
236
|
).to_return(status: 200, body: { "status" => "created", "url" => "monitorcalls.com" }.to_json, headers: { "Content-Type" => "application/json" })
|
237
237
|
service_response = service.register_callback(
|
@@ -239,11 +239,11 @@ class SpeechToTextV1Test < Minitest::Test
|
|
239
239
|
)
|
240
240
|
assert_equal({ "status" => "created", "url" => "monitorcalls.com" }, service_response.result)
|
241
241
|
|
242
|
-
stub_request(:post, "https://
|
242
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/unregister_callback?callback_url=monitorcalls.com")
|
243
243
|
.with(
|
244
244
|
headers: {
|
245
245
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
246
|
-
"Host" => "
|
246
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
247
247
|
}
|
248
248
|
).to_return(status: 200, body: { "response" => "The callback URL was successfully unregistered" }.to_json, headers: { "Content-Type" => "applicaton/json" })
|
249
249
|
service_response = service.unregister_callback(
|
@@ -260,25 +260,25 @@ class SpeechToTextV1Test < Minitest::Test
|
|
260
260
|
service = IBMWatson::SpeechToTextV1.new(
|
261
261
|
authenticator: authenticator
|
262
262
|
)
|
263
|
-
stub_request(:get, "https://
|
263
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations")
|
264
264
|
.with(
|
265
265
|
headers: {
|
266
266
|
"Accept" => "application/json",
|
267
267
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
268
|
-
"Host" => "
|
268
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
269
269
|
}
|
270
270
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
271
271
|
service_response = service.list_language_models
|
272
272
|
assert_equal({ "get response" => "yep" }, service_response.result)
|
273
273
|
|
274
|
-
stub_request(:post, "https://
|
274
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations")
|
275
275
|
.with(
|
276
276
|
body: "{\"name\":\"Example model\",\"base_model_name\":\"en-US_BroadbandModel\"}",
|
277
277
|
headers: {
|
278
278
|
"Accept" => "application/json",
|
279
279
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
280
280
|
"Content-Type" => "application/json",
|
281
|
-
"Host" => "
|
281
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
282
282
|
}
|
283
283
|
).to_return(status: 200, body: { "bogus_response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
284
284
|
service_response = service.create_language_model(
|
@@ -287,12 +287,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
287
287
|
)
|
288
288
|
assert_equal({ "bogus_response" => "yep" }, service_response.result)
|
289
289
|
|
290
|
-
stub_request(:post, "https://
|
290
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/customid/train")
|
291
291
|
.with(
|
292
292
|
headers: {
|
293
293
|
"Accept" => "application/json",
|
294
294
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
295
|
-
"Host" => "
|
295
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
296
296
|
}
|
297
297
|
).to_return(status: 200, body: { "bogus_response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
298
298
|
service_response = service.train_language_model(
|
@@ -300,12 +300,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
300
300
|
)
|
301
301
|
refute_nil(service_response)
|
302
302
|
|
303
|
-
stub_request(:get, "https://
|
303
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/modelid")
|
304
304
|
.with(
|
305
305
|
headers: {
|
306
306
|
"Accept" => "application/json",
|
307
307
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
308
|
-
"Host" => "
|
308
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
309
309
|
}
|
310
310
|
).to_return(status: 200, body: { "bogus_response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
311
311
|
service_response = service.get_language_model(
|
@@ -313,12 +313,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
313
313
|
)
|
314
314
|
assert_equal({ "bogus_response" => "yep" }, service_response.result)
|
315
315
|
|
316
|
-
stub_request(:delete, "https://
|
316
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/modelid")
|
317
317
|
.with(
|
318
318
|
headers: {
|
319
319
|
"Accept" => "application/json",
|
320
320
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
321
|
-
"Host" => "
|
321
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
322
322
|
}
|
323
323
|
).to_return(status: 200, body: { "bogus_response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
324
324
|
service_response = service.delete_language_model(
|
@@ -335,25 +335,25 @@ class SpeechToTextV1Test < Minitest::Test
|
|
335
335
|
service = IBMWatson::SpeechToTextV1.new(
|
336
336
|
authenticator: authenticator
|
337
337
|
)
|
338
|
-
stub_request(:get, "https://
|
338
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations")
|
339
339
|
.with(
|
340
340
|
headers: {
|
341
341
|
"Accept" => "application/json",
|
342
342
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
343
|
-
"Host" => "
|
343
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
344
344
|
}
|
345
345
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
346
346
|
service_response = service.list_acoustic_models
|
347
347
|
assert_equal({ "get response" => "yep" }, service_response.result)
|
348
348
|
|
349
|
-
stub_request(:post, "https://
|
349
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations")
|
350
350
|
.with(
|
351
351
|
body: "{\"name\":\"Example model\",\"base_model_name\":\"en-US_BroadbandModel\",\"description\":\"Example custom language model\"}",
|
352
352
|
headers: {
|
353
353
|
"Accept" => "application/json",
|
354
354
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
355
355
|
"Content-Type" => "application/json",
|
356
|
-
"Host" => "
|
356
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
357
357
|
}
|
358
358
|
).to_return(status: 200, body: { "bogus_response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
359
359
|
service_response = service.create_acoustic_model(
|
@@ -363,12 +363,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
363
363
|
)
|
364
364
|
assert_equal({ "bogus_response" => "yep" }, service_response.result)
|
365
365
|
|
366
|
-
stub_request(:post, "https://
|
366
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/customid/train")
|
367
367
|
.with(
|
368
368
|
headers: {
|
369
369
|
"Accept" => "application/json",
|
370
370
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
371
|
-
"Host" => "
|
371
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
372
372
|
}
|
373
373
|
).to_return(status: 200, body: "", headers: {})
|
374
374
|
service_response = service.train_acoustic_model(
|
@@ -376,12 +376,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
376
376
|
)
|
377
377
|
refute_nil(service_response)
|
378
378
|
|
379
|
-
stub_request(:get, "https://
|
379
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/modelid")
|
380
380
|
.with(
|
381
381
|
headers: {
|
382
382
|
"Accept" => "application/json",
|
383
383
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
384
|
-
"Host" => "
|
384
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
385
385
|
}
|
386
386
|
).to_return(status: 200, body: { "bogus_response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
387
387
|
service_response = service.get_acoustic_model(
|
@@ -389,12 +389,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
389
389
|
)
|
390
390
|
assert_equal({ "bogus_response" => "yep" }, service_response.result)
|
391
391
|
|
392
|
-
stub_request(:delete, "https://
|
392
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/modelid")
|
393
393
|
.with(
|
394
394
|
headers: {
|
395
395
|
"Accept" => "application/json",
|
396
396
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
397
|
-
"Host" => "
|
397
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
398
398
|
}
|
399
399
|
).to_return(status: 200, body: { "bogus_response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
400
400
|
service_response = service.delete_acoustic_model(
|
@@ -411,12 +411,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
411
411
|
service = IBMWatson::SpeechToTextV1.new(
|
412
412
|
authenticator: authenticator
|
413
413
|
)
|
414
|
-
stub_request(:get, "https://
|
414
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/customid/corpora")
|
415
415
|
.with(
|
416
416
|
headers: {
|
417
417
|
"Accept" => "application/json",
|
418
418
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
419
|
-
"Host" => "
|
419
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
420
420
|
}
|
421
421
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
422
422
|
service_response = service.list_corpora(
|
@@ -424,11 +424,11 @@ class SpeechToTextV1Test < Minitest::Test
|
|
424
424
|
)
|
425
425
|
assert_equal({ "get response" => "yep" }, service_response.result)
|
426
426
|
|
427
|
-
stub_request(:post, "https://
|
427
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/customid/corpora/corpus")
|
428
428
|
.with(
|
429
429
|
headers: {
|
430
430
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
431
|
-
"Host" => "
|
431
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
432
432
|
}
|
433
433
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
434
434
|
corpus_file = File.open(Dir.getwd + "/resources/speech_to_text/corpus-short-1.txt")
|
@@ -446,12 +446,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
446
446
|
)
|
447
447
|
assert_nil(service_response)
|
448
448
|
|
449
|
-
stub_request(:get, "https://
|
449
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/customid/corpora/corpus")
|
450
450
|
.with(
|
451
451
|
headers: {
|
452
452
|
"Accept" => "application/json",
|
453
453
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
454
|
-
"Host" => "
|
454
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
455
455
|
}
|
456
456
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
457
457
|
service_response = service.get_corpus(
|
@@ -460,12 +460,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
460
460
|
)
|
461
461
|
assert_equal({ "get response" => "yep" }, service_response.result)
|
462
462
|
|
463
|
-
stub_request(:delete, "https://
|
463
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/customid/corpora/corpus")
|
464
464
|
.with(
|
465
465
|
headers: {
|
466
466
|
"Accept" => "application/json",
|
467
467
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
468
|
-
"Host" => "
|
468
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
469
469
|
}
|
470
470
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
471
471
|
service_response = service.delete_corpus(
|
@@ -483,14 +483,14 @@ class SpeechToTextV1Test < Minitest::Test
|
|
483
483
|
service = IBMWatson::SpeechToTextV1.new(
|
484
484
|
authenticator: authenticator
|
485
485
|
)
|
486
|
-
stub_request(:put, "https://
|
486
|
+
stub_request(:put, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words/IEEE")
|
487
487
|
.with(
|
488
488
|
body: "{\"sounds_like\":[\"i triple e\"],\"display_as\":\"IEEE\"}",
|
489
489
|
headers: {
|
490
490
|
"Accept" => "application/json",
|
491
491
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
492
492
|
"Content-Type" => "application/json",
|
493
|
-
"Host" => "
|
493
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
494
494
|
}
|
495
495
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
496
496
|
service_response = service.add_word(
|
@@ -501,12 +501,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
501
501
|
)
|
502
502
|
assert_nil(service_response)
|
503
503
|
|
504
|
-
stub_request(:delete, "https://
|
504
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words/wordname")
|
505
505
|
.with(
|
506
506
|
headers: {
|
507
507
|
"Accept" => "application/json",
|
508
508
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
509
|
-
"Host" => "
|
509
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
510
510
|
}
|
511
511
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
512
512
|
service_response = service.delete_word(
|
@@ -515,12 +515,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
515
515
|
)
|
516
516
|
assert_nil(service_response)
|
517
517
|
|
518
|
-
stub_request(:delete, "https://
|
518
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words/IEEE")
|
519
519
|
.with(
|
520
520
|
headers: {
|
521
521
|
"Accept" => "application/json",
|
522
522
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
523
|
-
"Host" => "
|
523
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
524
524
|
}
|
525
525
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
526
526
|
service_response = service.delete_word(
|
@@ -536,14 +536,14 @@ class SpeechToTextV1Test < Minitest::Test
|
|
536
536
|
}
|
537
537
|
custom_words = [custom_word, custom_word, custom_word]
|
538
538
|
|
539
|
-
stub_request(:post, "https://
|
539
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words")
|
540
540
|
.with(
|
541
541
|
body: "{\"words\":[{\"word\":\"IEEE\",\"sounds_like\":[\" i triple e\"],\"display_as\":\"IEEE\"},{\"word\":\"IEEE\",\"sounds_like\":[\" i triple e\"],\"display_as\":\"IEEE\"},{\"word\":\"IEEE\",\"sounds_like\":[\" i triple e\"],\"display_as\":\"IEEE\"}]}",
|
542
542
|
headers: {
|
543
543
|
"Accept" => "application/json",
|
544
544
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
545
545
|
"Content-Type" => "application/json",
|
546
|
-
"Host" => "
|
546
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
547
547
|
}
|
548
548
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
549
549
|
service_response = service.add_words(
|
@@ -552,12 +552,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
552
552
|
)
|
553
553
|
assert_nil(service_response)
|
554
554
|
|
555
|
-
stub_request(:get, "https://
|
555
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words/IEEE")
|
556
556
|
.with(
|
557
557
|
headers: {
|
558
558
|
"Accept" => "application/json",
|
559
559
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
560
|
-
"Host" => "
|
560
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
561
561
|
}
|
562
562
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
563
563
|
service_response = service.get_word(
|
@@ -566,12 +566,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
566
566
|
)
|
567
567
|
assert_equal({ "get response" => "yep" }, service_response.result)
|
568
568
|
|
569
|
-
stub_request(:get, "https://
|
569
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words/wordname")
|
570
570
|
.with(
|
571
571
|
headers: {
|
572
572
|
"Accept" => "application/json",
|
573
573
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
574
|
-
"Host" => "
|
574
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
575
575
|
}
|
576
576
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
577
577
|
service_response = service.get_word(
|
@@ -580,12 +580,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
580
580
|
)
|
581
581
|
assert_equal({ "get response" => "yep" }, service_response.result)
|
582
582
|
|
583
|
-
stub_request(:get, "https://
|
583
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words")
|
584
584
|
.with(
|
585
585
|
headers: {
|
586
586
|
"Accept" => "application/json",
|
587
587
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
588
|
-
"Host" => "
|
588
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
589
589
|
}
|
590
590
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
591
591
|
service_response = service.list_words(
|
@@ -593,12 +593,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
593
593
|
)
|
594
594
|
assert_equal({ "get response" => "yep" }, service_response.result)
|
595
595
|
|
596
|
-
stub_request(:get, "https://
|
596
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words?sort=alphabetical")
|
597
597
|
.with(
|
598
598
|
headers: {
|
599
599
|
"Accept" => "application/json",
|
600
600
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
601
|
-
"Host" => "
|
601
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
602
602
|
}
|
603
603
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
604
604
|
service_response = service.list_words(
|
@@ -607,12 +607,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
607
607
|
)
|
608
608
|
assert_equal({ "get response" => "yep" }, service_response.result)
|
609
609
|
|
610
|
-
stub_request(:get, "https://
|
610
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/words?word_type=all")
|
611
611
|
.with(
|
612
612
|
headers: {
|
613
613
|
"Accept" => "application/json",
|
614
614
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
615
|
-
"Host" => "
|
615
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
616
616
|
}
|
617
617
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
618
618
|
service_response = service.list_words(
|
@@ -630,12 +630,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
630
630
|
service = IBMWatson::SpeechToTextV1.new(
|
631
631
|
authenticator: authenticator
|
632
632
|
)
|
633
|
-
stub_request(:get, "https://
|
633
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/grammars")
|
634
634
|
.with(
|
635
635
|
headers: {
|
636
636
|
"Accept" => "application/json",
|
637
637
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
638
|
-
"Host" => "
|
638
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
639
639
|
}
|
640
640
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
641
641
|
service_response = service.list_grammars(
|
@@ -652,12 +652,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
652
652
|
service = IBMWatson::SpeechToTextV1.new(
|
653
653
|
authenticator: authenticator
|
654
654
|
)
|
655
|
-
stub_request(:post, "https://
|
655
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/grammars/grammar")
|
656
656
|
.with(
|
657
657
|
headers: {
|
658
658
|
"Accept" => "application/json",
|
659
659
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
660
|
-
"Host" => "
|
660
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
661
661
|
}
|
662
662
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
663
663
|
response = service.add_grammar(
|
@@ -677,12 +677,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
677
677
|
service = IBMWatson::SpeechToTextV1.new(
|
678
678
|
authenticator: authenticator
|
679
679
|
)
|
680
|
-
stub_request(:get, "https://
|
680
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/grammars/grammar")
|
681
681
|
.with(
|
682
682
|
headers: {
|
683
683
|
"Accept" => "application/json",
|
684
684
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
685
|
-
"Host" => "
|
685
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
686
686
|
}
|
687
687
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
688
688
|
response = service.get_grammar(
|
@@ -700,12 +700,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
700
700
|
service = IBMWatson::SpeechToTextV1.new(
|
701
701
|
authenticator: authenticator
|
702
702
|
)
|
703
|
-
stub_request(:delete, "https://
|
703
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/custid/grammars/grammar")
|
704
704
|
.with(
|
705
705
|
headers: {
|
706
706
|
"Accept" => "application/json",
|
707
707
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
708
|
-
"Host" => "
|
708
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
709
709
|
}
|
710
710
|
).to_return(status: 200, body: { "get response" => "yep" }.to_json, headers: { "Content-Type" => "application/json" })
|
711
711
|
response = service.delete_grammar(
|
@@ -724,13 +724,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
724
724
|
authenticator: authenticator
|
725
725
|
)
|
726
726
|
audio_file = File.open(Dir.getwd + "/resources/speech.wav")
|
727
|
-
stub_request(:post, "https://
|
727
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/custid/audio/hiee")
|
728
728
|
.with(
|
729
729
|
headers: {
|
730
730
|
"Accept" => "application/json",
|
731
731
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
732
732
|
"Content-Type" => "application/json",
|
733
|
-
"Host" => "
|
733
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
734
734
|
}
|
735
735
|
).to_return(status: 200, body: { "post response" => "done" }.to_json, headers: { "Content-Type" => "application/json" })
|
736
736
|
service_response = service.add_audio(
|
@@ -741,12 +741,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
741
741
|
)
|
742
742
|
assert_nil(service_response)
|
743
743
|
|
744
|
-
stub_request(:delete, "https://
|
744
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/custid/audio/hiee")
|
745
745
|
.with(
|
746
746
|
headers: {
|
747
747
|
"Accept" => "application/json",
|
748
748
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
749
|
-
"Host" => "
|
749
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
750
750
|
}
|
751
751
|
).to_return(status: 200, body: { "post response" => "done" }.to_json, headers: { "Content-Type" => "application/json" })
|
752
752
|
service_response = service.delete_audio(
|
@@ -755,12 +755,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
755
755
|
)
|
756
756
|
assert_nil(service_response)
|
757
757
|
|
758
|
-
stub_request(:get, "https://
|
758
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/custid/audio/hiee")
|
759
759
|
.with(
|
760
760
|
headers: {
|
761
761
|
"Accept" => "application/json",
|
762
762
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
763
|
-
"Host" => "
|
763
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
764
764
|
}
|
765
765
|
).to_return(status: 200, body: { "get response" => "done" }.to_json, headers: { "Content-Type" => "application/json" })
|
766
766
|
service_response = service.get_audio(
|
@@ -769,12 +769,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
769
769
|
)
|
770
770
|
assert_equal({ "get response" => "done" }, service_response.result)
|
771
771
|
|
772
|
-
stub_request(:get, "https://
|
772
|
+
stub_request(:get, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/custid/audio")
|
773
773
|
.with(
|
774
774
|
headers: {
|
775
775
|
"Accept" => "application/json",
|
776
776
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
777
|
-
"Host" => "
|
777
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
778
778
|
}
|
779
779
|
).to_return(status: 200, body: { "get response all" => "done" }.to_json, headers: { "Content-Type" => "application/json" })
|
780
780
|
service_response = service.list_audio(
|
@@ -791,11 +791,11 @@ class SpeechToTextV1Test < Minitest::Test
|
|
791
791
|
service = IBMWatson::SpeechToTextV1.new(
|
792
792
|
authenticator: authenticator
|
793
793
|
)
|
794
|
-
stub_request(:delete, "https://
|
794
|
+
stub_request(:delete, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/user_data?customer_id=id")
|
795
795
|
.with(
|
796
796
|
headers: {
|
797
797
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
798
|
-
"Host" => "
|
798
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
799
799
|
}
|
800
800
|
).to_return(status: 200, body: { "description" => "success" }.to_json, headers: { "Content-Type" => "application/json" })
|
801
801
|
service_response = service.delete_user_data(
|
@@ -826,13 +826,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
826
826
|
],
|
827
827
|
"result_index" => 0
|
828
828
|
}
|
829
|
-
stub_request(:post, "https://
|
829
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognize")
|
830
830
|
.with(
|
831
831
|
headers: {
|
832
832
|
"Accept" => "application/json",
|
833
833
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
834
834
|
"Content-Type" => "audio/l16; rate=44100",
|
835
|
-
"Host" => "
|
835
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
836
836
|
}
|
837
837
|
).to_return(status: 200, body: recognize_response.to_json, headers: { "Content-Type" => "application/json" })
|
838
838
|
future = service.await.recognize(
|
@@ -865,13 +865,13 @@ class SpeechToTextV1Test < Minitest::Test
|
|
865
865
|
],
|
866
866
|
"result_index" => 0
|
867
867
|
}
|
868
|
-
stub_request(:post, "https://
|
868
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/recognize")
|
869
869
|
.with(
|
870
870
|
headers: {
|
871
871
|
"Accept" => "application/json",
|
872
872
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
873
873
|
"Content-Type" => "audio/l16; rate=44100",
|
874
|
-
"Host" => "
|
874
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
875
875
|
}
|
876
876
|
).to_return(status: 200, body: recognize_response.to_json, headers: { "Content-Type" => "application/json" })
|
877
877
|
future = service.async.recognize(
|
@@ -891,12 +891,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
891
891
|
service = IBMWatson::SpeechToTextV1.new(
|
892
892
|
authenticator: authenticator
|
893
893
|
)
|
894
|
-
stub_request(:post, "https://
|
894
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/customization_id/reset")
|
895
895
|
.with(
|
896
896
|
headers: {
|
897
897
|
"Accept" => "application/json",
|
898
898
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
899
|
-
"Host" => "
|
899
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
900
900
|
}
|
901
901
|
).to_return(status: 200, body: "", headers: {})
|
902
902
|
service_response = service.reset_language_model(customization_id: "customization_id")
|
@@ -911,12 +911,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
911
911
|
service = IBMWatson::SpeechToTextV1.new(
|
912
912
|
authenticator: authenticator
|
913
913
|
)
|
914
|
-
stub_request(:post, "https://
|
914
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/customizations/customization_id/upgrade_model")
|
915
915
|
.with(
|
916
916
|
headers: {
|
917
917
|
"Accept" => "application/json",
|
918
918
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
919
|
-
"Host" => "
|
919
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
920
920
|
}
|
921
921
|
).to_return(status: 200, body: "", headers: {})
|
922
922
|
service_response = service.upgrade_language_model(customization_id: "customization_id")
|
@@ -931,12 +931,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
931
931
|
service = IBMWatson::SpeechToTextV1.new(
|
932
932
|
authenticator: authenticator
|
933
933
|
)
|
934
|
-
stub_request(:post, "https://
|
934
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/customization_id/upgrade_model")
|
935
935
|
.with(
|
936
936
|
headers: {
|
937
937
|
"Accept" => "application/json",
|
938
938
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
939
|
-
"Host" => "
|
939
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
940
940
|
}
|
941
941
|
).to_return(status: 200, body: "", headers: {})
|
942
942
|
service_response = service.upgrade_acoustic_model(customization_id: "customization_id")
|
@@ -951,12 +951,12 @@ class SpeechToTextV1Test < Minitest::Test
|
|
951
951
|
service = IBMWatson::SpeechToTextV1.new(
|
952
952
|
authenticator: authenticator
|
953
953
|
)
|
954
|
-
stub_request(:post, "https://
|
954
|
+
stub_request(:post, "https://api.us-south.speech-to-text.watson.cloud.ibm.com/v1/acoustic_customizations/customization_id/reset")
|
955
955
|
.with(
|
956
956
|
headers: {
|
957
957
|
"Accept" => "application/json",
|
958
958
|
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
|
959
|
-
"Host" => "
|
959
|
+
"Host" => "api.us-south.speech-to-text.watson.cloud.ibm.com"
|
960
960
|
}
|
961
961
|
).to_return(status: 200, body: "", headers: {})
|
962
962
|
service_response = service.reset_acoustic_model(customization_id: "customization_id")
|