ibm_watson 0.5.1 → 0.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 +3 -2
- data/lib/ibm_watson/assistant_v1.rb +109 -101
- data/lib/ibm_watson/discovery_v1.rb +102 -77
- data/lib/ibm_watson/iam_token_manager.rb +25 -30
- data/lib/ibm_watson/language_translator_v3.rb +8 -77
- data/lib/ibm_watson/natural_language_classifier_v1.rb +11 -77
- data/lib/ibm_watson/natural_language_understanding_v1.rb +20 -82
- data/lib/ibm_watson/personality_insights_v3.rb +5 -77
- data/lib/ibm_watson/speech_to_text_v1.rb +139 -175
- data/lib/ibm_watson/text_to_speech_v1.rb +21 -77
- data/lib/ibm_watson/tone_analyzer_v3.rb +6 -77
- data/lib/ibm_watson/version.rb +1 -1
- data/lib/ibm_watson/visual_recognition_v3.rb +10 -76
- data/lib/ibm_watson/watson_service.rb +23 -17
- data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +1 -0
- data/test/integration/test_iam_assistant_v1.rb +3 -5
- data/test/unit/test_assistant_v1.rb +31 -0
- data/test/unit/test_configure_http_client.rb +0 -18
- data/test/unit/test_iam_token_manager.rb +21 -11
- data/test/unit/test_visual_recognition_v3.rb +1 -2
- metadata +2 -2
@@ -46,7 +46,7 @@ require_relative "./watson_service"
|
|
46
46
|
module IBMWatson
|
47
47
|
##
|
48
48
|
# The Personality Insights V3 service.
|
49
|
-
class PersonalityInsightsV3
|
49
|
+
class PersonalityInsightsV3 < WatsonService
|
50
50
|
include Concurrent::Async
|
51
51
|
##
|
52
52
|
# @!method initialize(args)
|
@@ -87,7 +87,6 @@ module IBMWatson
|
|
87
87
|
# 'https://iam.ng.bluemix.net/identity/token'.
|
88
88
|
def initialize(args = {})
|
89
89
|
@__async_initialized__ = false
|
90
|
-
super()
|
91
90
|
defaults = {}
|
92
91
|
defaults[:version] = nil
|
93
92
|
defaults[:url] = "https://gateway.watsonplatform.net/personality-insights/api"
|
@@ -97,84 +96,11 @@ module IBMWatson
|
|
97
96
|
defaults[:iam_access_token] = nil
|
98
97
|
defaults[:iam_url] = nil
|
99
98
|
args = defaults.merge(args)
|
100
|
-
|
101
|
-
|
102
|
-
url: args[:url],
|
103
|
-
username: args[:username],
|
104
|
-
password: args[:password],
|
105
|
-
iam_apikey: args[:iam_apikey],
|
106
|
-
iam_access_token: args[:iam_access_token],
|
107
|
-
iam_url: args[:iam_url],
|
108
|
-
use_vcap_services: true
|
109
|
-
)
|
99
|
+
args[:vcap_services_name] = "personality_insights"
|
100
|
+
super
|
110
101
|
@version = args[:version]
|
111
102
|
end
|
112
103
|
|
113
|
-
# :nocov:
|
114
|
-
def add_default_headers(headers: {})
|
115
|
-
@watson_service.add_default_headers(headers: headers)
|
116
|
-
end
|
117
|
-
|
118
|
-
def _iam_access_token(iam_access_token:)
|
119
|
-
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
120
|
-
end
|
121
|
-
|
122
|
-
def _iam_apikey(iam_apikey:)
|
123
|
-
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
124
|
-
end
|
125
|
-
|
126
|
-
# @return [DetailedResponse]
|
127
|
-
def request(args)
|
128
|
-
@watson_service.request(args)
|
129
|
-
end
|
130
|
-
|
131
|
-
# @note Chainable
|
132
|
-
# @param headers [Hash] Custom headers to be sent with the request
|
133
|
-
# @return [self]
|
134
|
-
def headers(headers)
|
135
|
-
@watson_service.headers(headers)
|
136
|
-
self
|
137
|
-
end
|
138
|
-
|
139
|
-
def password=(password)
|
140
|
-
@watson_service.password = password
|
141
|
-
end
|
142
|
-
|
143
|
-
def password
|
144
|
-
@watson_service.password
|
145
|
-
end
|
146
|
-
|
147
|
-
def username=(username)
|
148
|
-
@watson_service.username = username
|
149
|
-
end
|
150
|
-
|
151
|
-
def username
|
152
|
-
@watson_service.username
|
153
|
-
end
|
154
|
-
|
155
|
-
def url=(url)
|
156
|
-
@watson_service.url = url
|
157
|
-
end
|
158
|
-
|
159
|
-
def url
|
160
|
-
@watson_service.url
|
161
|
-
end
|
162
|
-
|
163
|
-
# @!method configure_http_client(proxy: {}, timeout: {})
|
164
|
-
# Sets the http client config, currently works with timeout and proxies
|
165
|
-
# @param proxy [Hash] The hash of proxy configurations
|
166
|
-
# @option proxy address [String] The address of the proxy
|
167
|
-
# @option proxy port [Integer] The port of the proxy
|
168
|
-
# @option proxy username [String] The username of the proxy, if authentication is needed
|
169
|
-
# @option proxy password [String] The password of the proxy, if authentication is needed
|
170
|
-
# @option proxy headers [Hash] The headers to be used with the proxy
|
171
|
-
# @param timeout [Hash] The hash for configuring timeouts. `per_operation` has priority over `global`
|
172
|
-
# @option timeout per_operation [Hash] Timeouts per operation. Requires `read`, `write`, `connect`
|
173
|
-
# @option timeout global [Integer] Upper bound on total request time
|
174
|
-
def configure_http_client(proxy: {}, timeout: {})
|
175
|
-
@watson_service.configure_http_client(proxy: proxy, timeout: timeout)
|
176
|
-
end
|
177
|
-
# :nocov:
|
178
104
|
#########################
|
179
105
|
# Methods
|
180
106
|
#########################
|
@@ -243,7 +169,9 @@ module IBMWatson
|
|
243
169
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
244
170
|
def profile(content:, content_type:, accept: nil, content_language: nil, accept_language: nil, raw_scores: nil, csv_headers: nil, consumption_preferences: nil)
|
245
171
|
raise ArgumentError("content must be provided") if content.nil?
|
172
|
+
|
246
173
|
raise ArgumentError("content_type must be provided") if content_type.nil?
|
174
|
+
|
247
175
|
headers = {
|
248
176
|
"Content-Type" => content_type,
|
249
177
|
"Accept" => accept,
|
@@ -17,40 +17,34 @@
|
|
17
17
|
# The IBM® Speech to Text service provides an API that uses IBM's speech-recognition
|
18
18
|
# capabilities to produce transcripts of spoken audio. The service can transcribe speech
|
19
19
|
# from various languages and audio formats. It addition to basic transcription, the
|
20
|
-
# service can produce detailed information about many aspects of the audio. For
|
21
|
-
# languages, the service supports two sampling rates, broadband and narrowband. It
|
22
|
-
# all JSON response content in the UTF-8 character set.
|
23
|
-
#
|
20
|
+
# service can produce detailed information about many different aspects of the audio. For
|
21
|
+
# most languages, the service supports two sampling rates, broadband and narrowband. It
|
22
|
+
# returns all JSON response content in the UTF-8 character set.
|
23
|
+
#
|
24
|
+
# For more information about the service, see the [IBM® Cloud
|
24
25
|
# documentation](https://console.bluemix.net/docs/services/speech-to-text/index.html).
|
25
26
|
#
|
26
27
|
# ### API usage guidelines
|
27
28
|
# * **Audio formats:** The service accepts audio in many formats (MIME types). See [Audio
|
28
29
|
# formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html).
|
29
|
-
# * **HTTP interfaces:** The service provides
|
30
|
-
# recognition. The
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
# HTTP
|
35
|
-
# and [The asynchronous HTTP
|
30
|
+
# * **HTTP interfaces:** The service provides two HTTP Representational State Transfer
|
31
|
+
# (REST) interfaces for speech recognition. The basic interface includes a single
|
32
|
+
# synchronous method. The asynchronous interface provides multiple methods that use
|
33
|
+
# registered callbacks and polling for non-blocking recognition. See [The HTTP
|
34
|
+
# interface](https://console.bluemix.net/docs/services/speech-to-text/http.html) and [The
|
35
|
+
# asynchronous HTTP
|
36
36
|
# interface](https://console.bluemix.net/docs/services/speech-to-text/async.html).
|
37
|
-
#
|
38
|
-
# **Important:** The session-based interface is deprecated as of August 8, 2018, and
|
39
|
-
# will be removed from service on September 7, 2018. Use the sessionless, asynchronous, or
|
40
|
-
# WebSocket interface instead. For more information, see the August 8 service update in
|
41
|
-
# the [Release
|
42
|
-
# notes](https://console.bluemix.net/docs/services/speech-to-text/release-notes.html#August2018).
|
43
37
|
# * **WebSocket interface:** The service also offers a WebSocket interface for speech
|
44
38
|
# recognition. The WebSocket interface provides a full-duplex, low-latency communication
|
45
39
|
# channel. Clients send requests and audio to the service and receive results over a
|
46
40
|
# single connection in an asynchronous fashion. See [The WebSocket
|
47
41
|
# interface](https://console.bluemix.net/docs/services/speech-to-text/websockets.html).
|
48
|
-
# * **Customization:**
|
49
|
-
#
|
50
|
-
# model
|
51
|
-
# generally available for production use by
|
52
|
-
# customization is beta functionality that is
|
53
|
-
# [The customization
|
42
|
+
# * **Customization:** The service offers two customization interfaces. Use language model
|
43
|
+
# customization to expand the vocabulary of a base model with domain-specific terminology.
|
44
|
+
# Use acoustic model customization to adapt a base model for the acoustic characteristics
|
45
|
+
# of your audio. Language model customization is generally available for production use by
|
46
|
+
# most supported languages; acoustic model customization is beta functionality that is
|
47
|
+
# available for all supported languages. See [The customization
|
54
48
|
# interface](https://console.bluemix.net/docs/services/speech-to-text/custom.html).
|
55
49
|
# * **Customization IDs:** Many methods accept a customization ID to identify a custom
|
56
50
|
# language or custom acoustic model. Customization IDs are Globally Unique Identifiers
|
@@ -84,7 +78,7 @@ require_relative "./watson_service"
|
|
84
78
|
module IBMWatson
|
85
79
|
##
|
86
80
|
# The Speech to Text V1 service.
|
87
|
-
class SpeechToTextV1
|
81
|
+
class SpeechToTextV1 < WatsonService
|
88
82
|
include Concurrent::Async
|
89
83
|
##
|
90
84
|
# @!method initialize(args)
|
@@ -115,7 +109,6 @@ module IBMWatson
|
|
115
109
|
# 'https://iam.ng.bluemix.net/identity/token'.
|
116
110
|
def initialize(args = {})
|
117
111
|
@__async_initialized__ = false
|
118
|
-
super()
|
119
112
|
defaults = {}
|
120
113
|
defaults[:url] = "https://stream.watsonplatform.net/speech-to-text/api"
|
121
114
|
defaults[:username] = nil
|
@@ -124,83 +117,10 @@ module IBMWatson
|
|
124
117
|
defaults[:iam_access_token] = nil
|
125
118
|
defaults[:iam_url] = nil
|
126
119
|
args = defaults.merge(args)
|
127
|
-
|
128
|
-
|
129
|
-
url: args[:url],
|
130
|
-
username: args[:username],
|
131
|
-
password: args[:password],
|
132
|
-
iam_apikey: args[:iam_apikey],
|
133
|
-
iam_access_token: args[:iam_access_token],
|
134
|
-
iam_url: args[:iam_url],
|
135
|
-
use_vcap_services: true
|
136
|
-
)
|
137
|
-
end
|
138
|
-
|
139
|
-
# :nocov:
|
140
|
-
def add_default_headers(headers: {})
|
141
|
-
@watson_service.add_default_headers(headers: headers)
|
142
|
-
end
|
143
|
-
|
144
|
-
def _iam_access_token(iam_access_token:)
|
145
|
-
@watson_service._iam_access_token(iam_access_token: iam_access_token)
|
146
|
-
end
|
147
|
-
|
148
|
-
def _iam_apikey(iam_apikey:)
|
149
|
-
@watson_service._iam_apikey(iam_apikey: iam_apikey)
|
150
|
-
end
|
151
|
-
|
152
|
-
# @return [DetailedResponse]
|
153
|
-
def request(args)
|
154
|
-
@watson_service.request(args)
|
155
|
-
end
|
156
|
-
|
157
|
-
# @note Chainable
|
158
|
-
# @param headers [Hash] Custom headers to be sent with the request
|
159
|
-
# @return [self]
|
160
|
-
def headers(headers)
|
161
|
-
@watson_service.headers(headers)
|
162
|
-
self
|
163
|
-
end
|
164
|
-
|
165
|
-
def password=(password)
|
166
|
-
@watson_service.password = password
|
167
|
-
end
|
168
|
-
|
169
|
-
def password
|
170
|
-
@watson_service.password
|
171
|
-
end
|
172
|
-
|
173
|
-
def username=(username)
|
174
|
-
@watson_service.username = username
|
175
|
-
end
|
176
|
-
|
177
|
-
def username
|
178
|
-
@watson_service.username
|
120
|
+
args[:vcap_services_name] = "speech_to_text"
|
121
|
+
super
|
179
122
|
end
|
180
123
|
|
181
|
-
def url=(url)
|
182
|
-
@watson_service.url = url
|
183
|
-
end
|
184
|
-
|
185
|
-
def url
|
186
|
-
@watson_service.url
|
187
|
-
end
|
188
|
-
|
189
|
-
# @!method configure_http_client(proxy: {}, timeout: {})
|
190
|
-
# Sets the http client config, currently works with timeout and proxies
|
191
|
-
# @param proxy [Hash] The hash of proxy configurations
|
192
|
-
# @option proxy address [String] The address of the proxy
|
193
|
-
# @option proxy port [Integer] The port of the proxy
|
194
|
-
# @option proxy username [String] The username of the proxy, if authentication is needed
|
195
|
-
# @option proxy password [String] The password of the proxy, if authentication is needed
|
196
|
-
# @option proxy headers [Hash] The headers to be used with the proxy
|
197
|
-
# @param timeout [Hash] The hash for configuring timeouts. `per_operation` has priority over `global`
|
198
|
-
# @option timeout per_operation [Hash] Timeouts per operation. Requires `read`, `write`, `connect`
|
199
|
-
# @option timeout global [Integer] Upper bound on total request time
|
200
|
-
def configure_http_client(proxy: {}, timeout: {})
|
201
|
-
@watson_service.configure_http_client(proxy: proxy, timeout: timeout)
|
202
|
-
end
|
203
|
-
# :nocov:
|
204
124
|
#########################
|
205
125
|
# Models
|
206
126
|
#########################
|
@@ -236,6 +156,7 @@ module IBMWatson
|
|
236
156
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
237
157
|
def get_model(model_id:)
|
238
158
|
raise ArgumentError("model_id must be provided") if model_id.nil?
|
159
|
+
|
239
160
|
headers = {
|
240
161
|
}
|
241
162
|
method_url = "/v1/models/%s" % [ERB::Util.url_encode(model_id)]
|
@@ -248,27 +169,27 @@ module IBMWatson
|
|
248
169
|
response
|
249
170
|
end
|
250
171
|
#########################
|
251
|
-
#
|
172
|
+
# Synchronous
|
252
173
|
#########################
|
253
174
|
|
254
175
|
##
|
255
176
|
# @!method recognize(audio:, content_type:, model: nil, customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil)
|
256
177
|
# Recognize audio.
|
257
|
-
# Sends audio and returns transcription results for a
|
258
|
-
#
|
259
|
-
#
|
260
|
-
#
|
261
|
-
#
|
262
|
-
#
|
178
|
+
# Sends audio and returns transcription results for a recognition request. Returns
|
179
|
+
# only the final results; to enable interim results, use the WebSocket API. The
|
180
|
+
# service imposes a data size limit of 100 MB. It automatically detects the
|
181
|
+
# endianness of the incoming audio and, for audio that includes multiple channels,
|
182
|
+
# downmixes the audio to one-channel mono during transcoding. (For the `audio/l16`
|
183
|
+
# format, you can specify the endianness.)
|
263
184
|
#
|
264
185
|
# ### Streaming mode
|
265
186
|
#
|
266
187
|
# For requests to transcribe live audio as it becomes available, you must set the
|
267
188
|
# `Transfer-Encoding` header to `chunked` to use streaming mode. In streaming mode,
|
268
189
|
# the server closes the connection (status code 408) if the service receives no data
|
269
|
-
# chunk for 30 seconds and
|
270
|
-
#
|
271
|
-
#
|
190
|
+
# chunk for 30 seconds and it has no audio to transcribe for 30 seconds. The server
|
191
|
+
# also closes the connection (status code 400) if no speech is detected for
|
192
|
+
# `inactivity_timeout` seconds of audio (not processing time); use the
|
272
193
|
# `inactivity_timeout` parameter to change the default of 30 seconds.
|
273
194
|
#
|
274
195
|
# ### Audio formats (content types)
|
@@ -307,38 +228,32 @@ module IBMWatson
|
|
307
228
|
# limit imposed by most HTTP servers and proxies. You can encounter this limit, for
|
308
229
|
# example, if you want to spot a very large number of keywords.
|
309
230
|
#
|
310
|
-
# For information about submitting a multipart request, see [
|
311
|
-
#
|
312
|
-
# data](https://console.bluemix.net/docs/services/speech-to-text/http.html#HTTP-multi).
|
231
|
+
# For information about submitting a multipart request, see [Making a multipart HTTP
|
232
|
+
# request](https://console.bluemix.net/docs/services/speech-to-text/http.html#HTTP-multi).
|
313
233
|
# @param audio [String] The audio to transcribe in the format specified by the `Content-Type` header.
|
314
234
|
# @param content_type [String] The type of the input.
|
315
|
-
# @param model [String] The identifier of the model that is to be used for the recognition request
|
316
|
-
# the **Create a session** method, with the new session.
|
235
|
+
# @param model [String] The identifier of the model that is to be used for the recognition request.
|
317
236
|
# @param customization_id [String] The customization ID (GUID) of a custom language model that is to be used with the
|
318
|
-
# recognition request
|
319
|
-
#
|
320
|
-
#
|
321
|
-
#
|
322
|
-
# default, no custom language model is used.
|
237
|
+
# recognition request. The base model of the specified custom language model must
|
238
|
+
# match the model specified with the `model` parameter. You must make the request
|
239
|
+
# with service credentials created for the instance of the service that owns the
|
240
|
+
# custom model. By default, no custom language model is used.
|
323
241
|
# @param acoustic_customization_id [String] The customization ID (GUID) of a custom acoustic model that is to be used with the
|
324
|
-
# recognition request
|
325
|
-
#
|
326
|
-
#
|
327
|
-
#
|
328
|
-
# default, no custom acoustic model is used.
|
242
|
+
# recognition request. The base model of the specified custom acoustic model must
|
243
|
+
# match the model specified with the `model` parameter. You must make the request
|
244
|
+
# with service credentials created for the instance of the service that owns the
|
245
|
+
# custom model. By default, no custom acoustic model is used.
|
329
246
|
# @param base_model_version [String] The version of the specified base model that is to be used with recognition
|
330
|
-
# request
|
331
|
-
#
|
332
|
-
#
|
333
|
-
#
|
334
|
-
#
|
335
|
-
# model
|
247
|
+
# request. Multiple versions of a base model can exist when a model is updated for
|
248
|
+
# internal improvements. The parameter is intended primarily for use with custom
|
249
|
+
# models that have been upgraded for a new base model. The default value depends on
|
250
|
+
# whether the parameter is used with or without a custom model. For more
|
251
|
+
# information, see [Base model
|
336
252
|
# version](https://console.bluemix.net/docs/services/speech-to-text/input.html#version).
|
337
253
|
# @param customization_weight [Float] If you specify the customization ID (GUID) of a custom language model with the
|
338
|
-
# recognition request
|
339
|
-
#
|
340
|
-
#
|
341
|
-
# request.
|
254
|
+
# recognition request, the customization weight tells the service how much weight to
|
255
|
+
# give to words from the custom language model compared to those from the base model
|
256
|
+
# for the current request.
|
342
257
|
#
|
343
258
|
# Specify a value between 0.0 and 1.0. Unless a different customization weight was
|
344
259
|
# specified for the custom model when it was trained, the default value is 0.3. A
|
@@ -397,7 +312,9 @@ module IBMWatson
|
|
397
312
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
398
313
|
def recognize(audio:, content_type:, model: nil, customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil)
|
399
314
|
raise ArgumentError("audio must be provided") if audio.nil?
|
315
|
+
|
400
316
|
raise ArgumentError("content_type must be provided") if content_type.nil?
|
317
|
+
|
401
318
|
headers = {
|
402
319
|
"Content-Type" => content_type
|
403
320
|
}
|
@@ -480,16 +397,17 @@ module IBMWatson
|
|
480
397
|
raise ArgumentError("Audio must be provided") if audio.nil? && !chunk_data
|
481
398
|
raise ArgumentError("Recognize callback must be provided") if recognize_callback.nil?
|
482
399
|
raise TypeError("Callback is not a derived class of RecognizeCallback") unless recognize_callback.is_a?(IBMWatson::RecognizeCallback)
|
400
|
+
|
483
401
|
require_relative("./websocket/speech_to_text_websocket_listener.rb")
|
484
402
|
headers = {}
|
485
|
-
headers =
|
486
|
-
if
|
487
|
-
access_token =
|
403
|
+
headers = conn.default_options.headers.to_hash unless conn.default_options.headers.to_hash.empty?
|
404
|
+
if !token_manager.nil?
|
405
|
+
access_token = token_manager.token
|
488
406
|
headers["Authorization"] = "Bearer #{access_token}"
|
489
|
-
elsif
|
490
|
-
headers["Authorization"] = "Basic " + Base64.strict_encode64("#{
|
407
|
+
elsif !username.nil? && !password.nil?
|
408
|
+
headers["Authorization"] = "Basic " + Base64.strict_encode64("#{username}:#{password}")
|
491
409
|
end
|
492
|
-
url = @
|
410
|
+
url = @url.gsub("https:", "wss:")
|
493
411
|
params = {
|
494
412
|
"model" => model,
|
495
413
|
"customization_id" => customization_id,
|
@@ -618,6 +536,7 @@ module IBMWatson
|
|
618
536
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
619
537
|
def register_callback(callback_url:, user_secret: nil)
|
620
538
|
raise ArgumentError("callback_url must be provided") if callback_url.nil?
|
539
|
+
|
621
540
|
headers = {
|
622
541
|
}
|
623
542
|
params = {
|
@@ -645,6 +564,7 @@ module IBMWatson
|
|
645
564
|
# @return [nil]
|
646
565
|
def unregister_callback(callback_url:)
|
647
566
|
raise ArgumentError("callback_url must be provided") if callback_url.nil?
|
567
|
+
|
648
568
|
headers = {
|
649
569
|
}
|
650
570
|
params = {
|
@@ -726,8 +646,7 @@ module IBMWatson
|
|
726
646
|
# formats](https://console.bluemix.net/docs/services/speech-to-text/audio-formats.html).
|
727
647
|
# @param audio [String] The audio to transcribe in the format specified by the `Content-Type` header.
|
728
648
|
# @param content_type [String] The type of the input.
|
729
|
-
# @param model [String] The identifier of the model that is to be used for the recognition request
|
730
|
-
# the **Create a session** method, with the new session.
|
649
|
+
# @param model [String] The identifier of the model that is to be used for the recognition request.
|
731
650
|
# @param callback_url [String] A URL to which callback notifications are to be sent. The URL must already be
|
732
651
|
# successfully white-listed by using the **Register a callback** method. You can
|
733
652
|
# include the same callback URL with any number of job creation requests. Omit the
|
@@ -747,10 +666,12 @@ module IBMWatson
|
|
747
666
|
# * `recognitions.failed` generates a callback notification if the service
|
748
667
|
# experiences an error while processing the job.
|
749
668
|
#
|
750
|
-
#
|
751
|
-
#
|
752
|
-
#
|
753
|
-
#
|
669
|
+
# The `recognitions.completed` and `recognitions.completed_with_results` events are
|
670
|
+
# incompatible. You can specify only of the two events.
|
671
|
+
#
|
672
|
+
# If the job includes a callback URL, omit the parameter to subscribe to the default
|
673
|
+
# events: `recognitions.started`, `recognitions.completed`, and
|
674
|
+
# `recognitions.failed`. If the job does not include a callback URL, omit the
|
754
675
|
# parameter.
|
755
676
|
# @param user_token [String] If the job includes a callback URL, a user-specified string that the service is to
|
756
677
|
# include with each callback notification for the job; the token allows the user to
|
@@ -761,30 +682,26 @@ module IBMWatson
|
|
761
682
|
# this time. Omit the parameter to use a time to live of one week. The parameter is
|
762
683
|
# valid with or without a callback URL.
|
763
684
|
# @param customization_id [String] The customization ID (GUID) of a custom language model that is to be used with the
|
764
|
-
# recognition request
|
765
|
-
#
|
766
|
-
#
|
767
|
-
#
|
768
|
-
# default, no custom language model is used.
|
685
|
+
# recognition request. The base model of the specified custom language model must
|
686
|
+
# match the model specified with the `model` parameter. You must make the request
|
687
|
+
# with service credentials created for the instance of the service that owns the
|
688
|
+
# custom model. By default, no custom language model is used.
|
769
689
|
# @param acoustic_customization_id [String] The customization ID (GUID) of a custom acoustic model that is to be used with the
|
770
|
-
# recognition request
|
771
|
-
#
|
772
|
-
#
|
773
|
-
#
|
774
|
-
# default, no custom acoustic model is used.
|
690
|
+
# recognition request. The base model of the specified custom acoustic model must
|
691
|
+
# match the model specified with the `model` parameter. You must make the request
|
692
|
+
# with service credentials created for the instance of the service that owns the
|
693
|
+
# custom model. By default, no custom acoustic model is used.
|
775
694
|
# @param base_model_version [String] The version of the specified base model that is to be used with recognition
|
776
|
-
# request
|
777
|
-
#
|
778
|
-
#
|
779
|
-
#
|
780
|
-
#
|
781
|
-
# model
|
695
|
+
# request. Multiple versions of a base model can exist when a model is updated for
|
696
|
+
# internal improvements. The parameter is intended primarily for use with custom
|
697
|
+
# models that have been upgraded for a new base model. The default value depends on
|
698
|
+
# whether the parameter is used with or without a custom model. For more
|
699
|
+
# information, see [Base model
|
782
700
|
# version](https://console.bluemix.net/docs/services/speech-to-text/input.html#version).
|
783
701
|
# @param customization_weight [Float] If you specify the customization ID (GUID) of a custom language model with the
|
784
|
-
# recognition request
|
785
|
-
#
|
786
|
-
#
|
787
|
-
# request.
|
702
|
+
# recognition request, the customization weight tells the service how much weight to
|
703
|
+
# give to words from the custom language model compared to those from the base model
|
704
|
+
# for the current request.
|
788
705
|
#
|
789
706
|
# Specify a value between 0.0 and 1.0. Unless a different customization weight was
|
790
707
|
# specified for the custom model when it was trained, the default value is 0.3. A
|
@@ -843,7 +760,9 @@ module IBMWatson
|
|
843
760
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
844
761
|
def create_job(audio:, content_type:, model: nil, callback_url: nil, events: nil, user_token: nil, results_ttl: nil, customization_id: nil, acoustic_customization_id: nil, base_model_version: nil, customization_weight: nil, inactivity_timeout: nil, keywords: nil, keywords_threshold: nil, max_alternatives: nil, word_alternatives_threshold: nil, word_confidence: nil, timestamps: nil, profanity_filter: nil, smart_formatting: nil, speaker_labels: nil)
|
845
762
|
raise ArgumentError("audio must be provided") if audio.nil?
|
763
|
+
|
846
764
|
raise ArgumentError("content_type must be provided") if content_type.nil?
|
765
|
+
|
847
766
|
headers = {
|
848
767
|
"Content-Type" => content_type
|
849
768
|
}
|
@@ -923,6 +842,7 @@ module IBMWatson
|
|
923
842
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
924
843
|
def check_job(id:)
|
925
844
|
raise ArgumentError("id must be provided") if id.nil?
|
845
|
+
|
926
846
|
headers = {
|
927
847
|
}
|
928
848
|
method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
|
@@ -947,6 +867,7 @@ module IBMWatson
|
|
947
867
|
# @return [nil]
|
948
868
|
def delete_job(id:)
|
949
869
|
raise ArgumentError("id must be provided") if id.nil?
|
870
|
+
|
950
871
|
headers = {
|
951
872
|
}
|
952
873
|
method_url = "/v1/recognitions/%s" % [ERB::Util.url_encode(id)]
|
@@ -996,7 +917,9 @@ module IBMWatson
|
|
996
917
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
997
918
|
def create_language_model(name:, base_model_name:, dialect: nil, description: nil)
|
998
919
|
raise ArgumentError("name must be provided") if name.nil?
|
920
|
+
|
999
921
|
raise ArgumentError("base_model_name must be provided") if base_model_name.nil?
|
922
|
+
|
1000
923
|
headers = {
|
1001
924
|
}
|
1002
925
|
data = {
|
@@ -1056,6 +979,7 @@ module IBMWatson
|
|
1056
979
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1057
980
|
def get_language_model(customization_id:)
|
1058
981
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
982
|
+
|
1059
983
|
headers = {
|
1060
984
|
}
|
1061
985
|
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
@@ -1081,6 +1005,7 @@ module IBMWatson
|
|
1081
1005
|
# @return [nil]
|
1082
1006
|
def delete_language_model(customization_id:)
|
1083
1007
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1008
|
+
|
1084
1009
|
headers = {
|
1085
1010
|
}
|
1086
1011
|
method_url = "/v1/customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
@@ -1148,6 +1073,7 @@ module IBMWatson
|
|
1148
1073
|
# @return [nil]
|
1149
1074
|
def train_language_model(customization_id:, word_type_to_add: nil, customization_weight: nil)
|
1150
1075
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1076
|
+
|
1151
1077
|
headers = {
|
1152
1078
|
}
|
1153
1079
|
params = {
|
@@ -1179,6 +1105,7 @@ module IBMWatson
|
|
1179
1105
|
# @return [nil]
|
1180
1106
|
def reset_language_model(customization_id:)
|
1181
1107
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1108
|
+
|
1182
1109
|
headers = {
|
1183
1110
|
}
|
1184
1111
|
method_url = "/v1/customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
|
@@ -1218,6 +1145,7 @@ module IBMWatson
|
|
1218
1145
|
# @return [nil]
|
1219
1146
|
def upgrade_language_model(customization_id:)
|
1220
1147
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1148
|
+
|
1221
1149
|
headers = {
|
1222
1150
|
}
|
1223
1151
|
method_url = "/v1/customizations/%s/upgrade_model" % [ERB::Util.url_encode(customization_id)]
|
@@ -1246,6 +1174,7 @@ module IBMWatson
|
|
1246
1174
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1247
1175
|
def list_corpora(customization_id:)
|
1248
1176
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1177
|
+
|
1249
1178
|
headers = {
|
1250
1179
|
}
|
1251
1180
|
method_url = "/v1/customizations/%s/corpora" % [ERB::Util.url_encode(customization_id)]
|
@@ -1322,8 +1251,11 @@ module IBMWatson
|
|
1322
1251
|
# @return [nil]
|
1323
1252
|
def add_corpus(customization_id:, corpus_name:, corpus_file:, allow_overwrite: nil, corpus_filename: nil)
|
1324
1253
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1254
|
+
|
1325
1255
|
raise ArgumentError("corpus_name must be provided") if corpus_name.nil?
|
1256
|
+
|
1326
1257
|
raise ArgumentError("corpus_file must be provided") if corpus_file.nil?
|
1258
|
+
|
1327
1259
|
headers = {
|
1328
1260
|
}
|
1329
1261
|
params = {
|
@@ -1369,7 +1301,9 @@ module IBMWatson
|
|
1369
1301
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1370
1302
|
def get_corpus(customization_id:, corpus_name:)
|
1371
1303
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1304
|
+
|
1372
1305
|
raise ArgumentError("corpus_name must be provided") if corpus_name.nil?
|
1306
|
+
|
1373
1307
|
headers = {
|
1374
1308
|
}
|
1375
1309
|
method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
|
@@ -1402,7 +1336,9 @@ module IBMWatson
|
|
1402
1336
|
# @return [nil]
|
1403
1337
|
def delete_corpus(customization_id:, corpus_name:)
|
1404
1338
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1339
|
+
|
1405
1340
|
raise ArgumentError("corpus_name must be provided") if corpus_name.nil?
|
1341
|
+
|
1406
1342
|
headers = {
|
1407
1343
|
}
|
1408
1344
|
method_url = "/v1/customizations/%s/corpora/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(corpus_name)]
|
@@ -1445,6 +1381,7 @@ module IBMWatson
|
|
1445
1381
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1446
1382
|
def list_words(customization_id:, word_type: nil, sort: nil)
|
1447
1383
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1384
|
+
|
1448
1385
|
headers = {
|
1449
1386
|
}
|
1450
1387
|
params = {
|
@@ -1525,7 +1462,9 @@ module IBMWatson
|
|
1525
1462
|
# @return [nil]
|
1526
1463
|
def add_words(customization_id:, words:)
|
1527
1464
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1465
|
+
|
1528
1466
|
raise ArgumentError("words must be provided") if words.nil?
|
1467
|
+
|
1529
1468
|
headers = {
|
1530
1469
|
}
|
1531
1470
|
data = {
|
@@ -1592,21 +1531,25 @@ module IBMWatson
|
|
1592
1531
|
# Omit this field for the **Add a custom word** method.
|
1593
1532
|
# @param sounds_like [Array[String]] An array of sounds-like pronunciations for the custom word. Specify how words that
|
1594
1533
|
# are difficult to pronounce, foreign words, acronyms, and so on can be pronounced
|
1595
|
-
# by users.
|
1596
|
-
#
|
1597
|
-
#
|
1598
|
-
#
|
1599
|
-
#
|
1600
|
-
# pronunciation
|
1601
|
-
#
|
1602
|
-
#
|
1534
|
+
# by users.
|
1535
|
+
# * For a word that is not in the service's base vocabulary, omit the parameter to
|
1536
|
+
# have the service automatically generate a sounds-like pronunciation for the word.
|
1537
|
+
# * For a word that is in the service's base vocabulary, use the parameter to
|
1538
|
+
# specify additional pronunciations for the word. You cannot override the default
|
1539
|
+
# pronunciation of a word; pronunciations you add augment the pronunciation from the
|
1540
|
+
# base vocabulary.
|
1541
|
+
#
|
1542
|
+
# A word can have at most five sounds-like pronunciations. A pronunciation can
|
1543
|
+
# include at most 40 characters not including spaces.
|
1603
1544
|
# @param display_as [String] An alternative spelling for the custom word when it appears in a transcript. Use
|
1604
1545
|
# the parameter when you want the word to have a spelling that is different from its
|
1605
1546
|
# usual representation or from its spelling in corpora training data.
|
1606
1547
|
# @return [nil]
|
1607
1548
|
def add_word(customization_id:, word_name:, word: nil, sounds_like: nil, display_as: nil)
|
1608
1549
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1550
|
+
|
1609
1551
|
raise ArgumentError("word_name must be provided") if word_name.nil?
|
1552
|
+
|
1610
1553
|
headers = {
|
1611
1554
|
}
|
1612
1555
|
data = {
|
@@ -1640,7 +1583,9 @@ module IBMWatson
|
|
1640
1583
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1641
1584
|
def get_word(customization_id:, word_name:)
|
1642
1585
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1586
|
+
|
1643
1587
|
raise ArgumentError("word_name must be provided") if word_name.nil?
|
1588
|
+
|
1644
1589
|
headers = {
|
1645
1590
|
}
|
1646
1591
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
|
@@ -1672,7 +1617,9 @@ module IBMWatson
|
|
1672
1617
|
# @return [nil]
|
1673
1618
|
def delete_word(customization_id:, word_name:)
|
1674
1619
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1620
|
+
|
1675
1621
|
raise ArgumentError("word_name must be provided") if word_name.nil?
|
1622
|
+
|
1676
1623
|
headers = {
|
1677
1624
|
}
|
1678
1625
|
method_url = "/v1/customizations/%s/words/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(word_name)]
|
@@ -1710,7 +1657,9 @@ module IBMWatson
|
|
1710
1657
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1711
1658
|
def create_acoustic_model(name:, base_model_name:, description: nil)
|
1712
1659
|
raise ArgumentError("name must be provided") if name.nil?
|
1660
|
+
|
1713
1661
|
raise ArgumentError("base_model_name must be provided") if base_model_name.nil?
|
1662
|
+
|
1714
1663
|
headers = {
|
1715
1664
|
}
|
1716
1665
|
data = {
|
@@ -1769,6 +1718,7 @@ module IBMWatson
|
|
1769
1718
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1770
1719
|
def get_acoustic_model(customization_id:)
|
1771
1720
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1721
|
+
|
1772
1722
|
headers = {
|
1773
1723
|
}
|
1774
1724
|
method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
@@ -1794,6 +1744,7 @@ module IBMWatson
|
|
1794
1744
|
# @return [nil]
|
1795
1745
|
def delete_acoustic_model(customization_id:)
|
1796
1746
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1747
|
+
|
1797
1748
|
headers = {
|
1798
1749
|
}
|
1799
1750
|
method_url = "/v1/acoustic_customizations/%s" % [ERB::Util.url_encode(customization_id)]
|
@@ -1858,6 +1809,7 @@ module IBMWatson
|
|
1858
1809
|
# @return [nil]
|
1859
1810
|
def train_acoustic_model(customization_id:, custom_language_model_id: nil)
|
1860
1811
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1812
|
+
|
1861
1813
|
headers = {
|
1862
1814
|
}
|
1863
1815
|
params = {
|
@@ -1888,6 +1840,7 @@ module IBMWatson
|
|
1888
1840
|
# @return [nil]
|
1889
1841
|
def reset_acoustic_model(customization_id:)
|
1890
1842
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1843
|
+
|
1891
1844
|
headers = {
|
1892
1845
|
}
|
1893
1846
|
method_url = "/v1/acoustic_customizations/%s/reset" % [ERB::Util.url_encode(customization_id)]
|
@@ -1937,6 +1890,7 @@ module IBMWatson
|
|
1937
1890
|
# @return [nil]
|
1938
1891
|
def upgrade_acoustic_model(customization_id:, custom_language_model_id: nil)
|
1939
1892
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1893
|
+
|
1940
1894
|
headers = {
|
1941
1895
|
}
|
1942
1896
|
params = {
|
@@ -1971,6 +1925,7 @@ module IBMWatson
|
|
1971
1925
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
1972
1926
|
def list_audio(customization_id:)
|
1973
1927
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
1928
|
+
|
1974
1929
|
headers = {
|
1975
1930
|
}
|
1976
1931
|
method_url = "/v1/acoustic_customizations/%s/audio" % [ERB::Util.url_encode(customization_id)]
|
@@ -2090,9 +2045,13 @@ module IBMWatson
|
|
2090
2045
|
# @return [nil]
|
2091
2046
|
def add_audio(customization_id:, audio_name:, audio_resource:, content_type:, contained_content_type: nil, allow_overwrite: nil)
|
2092
2047
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
2048
|
+
|
2093
2049
|
raise ArgumentError("audio_name must be provided") if audio_name.nil?
|
2050
|
+
|
2094
2051
|
raise ArgumentError("audio_resource must be provided") if audio_resource.nil?
|
2052
|
+
|
2095
2053
|
raise ArgumentError("content_type must be provided") if content_type.nil?
|
2054
|
+
|
2096
2055
|
headers = {
|
2097
2056
|
"Content-Type" => content_type,
|
2098
2057
|
"Contained-Content-Type" => contained_content_type
|
@@ -2145,7 +2104,9 @@ module IBMWatson
|
|
2145
2104
|
# @return [DetailedResponse] A `DetailedResponse` object representing the response.
|
2146
2105
|
def get_audio(customization_id:, audio_name:)
|
2147
2106
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
2107
|
+
|
2148
2108
|
raise ArgumentError("audio_name must be provided") if audio_name.nil?
|
2109
|
+
|
2149
2110
|
headers = {
|
2150
2111
|
}
|
2151
2112
|
method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
|
@@ -2177,7 +2138,9 @@ module IBMWatson
|
|
2177
2138
|
# @return [nil]
|
2178
2139
|
def delete_audio(customization_id:, audio_name:)
|
2179
2140
|
raise ArgumentError("customization_id must be provided") if customization_id.nil?
|
2141
|
+
|
2180
2142
|
raise ArgumentError("audio_name must be provided") if audio_name.nil?
|
2143
|
+
|
2181
2144
|
headers = {
|
2182
2145
|
}
|
2183
2146
|
method_url = "/v1/acoustic_customizations/%s/audio/%s" % [ERB::Util.url_encode(customization_id), ERB::Util.url_encode(audio_name)]
|
@@ -2210,6 +2173,7 @@ module IBMWatson
|
|
2210
2173
|
# @return [nil]
|
2211
2174
|
def delete_user_data(customer_id:)
|
2212
2175
|
raise ArgumentError("customer_id must be provided") if customer_id.nil?
|
2176
|
+
|
2213
2177
|
headers = {
|
2214
2178
|
}
|
2215
2179
|
params = {
|