You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -55,7 +55,8 @@ Watson services are migrating to token-based Identity and Access Management (IAM
55
55
56
56
- With some service instances, you authenticate to the API by using **[IAM](#iam)**.
57
57
- In other instances, you authenticate by providing the **[username and password](#username-and-password)** for the service instance.
58
-
- If you're using a Watson service on ICP, you'll need to authenticate in [a specific way](#icp).
58
+
- If you are using a Watson service on ICP, you will need to authenticate in [a specific way](#icp).
59
+
- If you are using a Watson service on AWS, you will need to authenticate using [mcsp](#mcsp).
59
60
60
61
Authentication is accomplished using dedicated Authenticators for each authentication scheme. Import authenticators from `ibm-watson/auth` or rely on externally-configured credentials which will be read from a credentials file or environment variables.
61
62
@@ -89,32 +90,26 @@ The file downloaded will be called `ibm-credentials.env`. This is the name the S
89
90
- Your system's home directory
90
91
- Your current working directory (the directory Node is executed from)
91
92
92
-
As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Discovery instance, you just need to do the following:
93
+
As long as you set that up correctly, you don't have to worry about setting any authentication options in your code. So, for example, if you created and downloaded the credential file for your Assistant instance, you just need to do the following:
If you're using more than one service at a time in your code and get two different `ibm-credentials.env` files, just put the contents together in one `ibm-credentials.env` file and the SDK will handle assigning credentials to their appropriate services.
102
103
103
-
**Special Note**: Due to legacy issues in Assistant V1 and V2 as well as Visual Recognition V3 and V4, the following parameter `serviceName` must be added when creating the service object:
104
+
**Special Note**: Due to legacy issues in Assistant V1 and V2, the following parameter `serviceName` must be added when creating the service object:
It is worth noting that if you are planning to rely on VCAP_SERVICES for authentication then the `serviceName` parameter **MUST** be removed otherwise VCAP_SERVICES will not be able to authenticate you. See [Cloud Authentication Prioritization](#cloud-authentication-prioritization) for more details.
119
114
120
115
If you would like to configure the location/name of your credential file, you can set an environment variable called `IBM_CREDENTIALS_FILE`. **This will take precedence over the locations specified above.** Here's how you can do that:
@@ -154,7 +149,7 @@ const authenticator = new McspAuthenticator({
All SDK methods are asynchronous, as they are making network requests to Watson services. To handle receiving the data from these requests, the SDK offers support with Promises.
// using Promises provides the ability to use async / await
202
-
asyncfunctioncallDiscovery() { // note that callDiscovery also returns a Promise
203
-
constbody=awaitdiscovery.listEnvironments();
197
+
asyncfunctioncallAssistant() { // note that callAssistant also returns a Promise
198
+
constbody=awaitassistant.listAssistants();
204
199
}
205
200
```
206
201
@@ -211,7 +206,7 @@ Custom headers can be passed with any request. Each method has an optional param
211
206
For example, this is how you can pass in custom headers to Watson Assistant service. In this example, the `'custom'` value for `'Accept-Language'` will override the default header for `'Accept-Language'`, and the `'Custom-Header'` while not overriding the default headers, will additionally be sent with the request.
212
207
213
208
```js
214
-
constassistant=newwatson.AssistantV1({
209
+
constassistant=newwatson.AssistantV2({
215
210
/* authenticator, version, serviceUrl, etc... */
216
211
});
217
212
@@ -238,7 +233,7 @@ The SDK now returns the full HTTP response by default for each method.
238
233
Here is an example of how to access the response headers for Watson Assistant:
Every SDK call returns a response with a transaction ID in the `X-Global-Transaction-Id` header. Together the service instance region, this ID helps support teams troubleshoot issues from relevant logs.
259
+
Every SDK call returns a response with a transaction ID in the `X-Global-Transaction-Id` header. Together with the service instance region, this ID helps support teams troubleshoot issues from relevant logs.
However, the transaction ID isn't available when the API doesn't return a response for some reason. In that case, you can set your own transaction ID in the request. For example, replace `<my-unique-transaction-id>` in the following example with a unique transaction ID.
297
292
298
293
```js
299
-
constassistant=newAssistantV1({
294
+
constassistant=newAssistantV2({
300
295
/* authenticator, version, serviceUrl, etc... */
301
296
});
302
297
@@ -338,7 +333,7 @@ To use the SDK (which makes HTTPS requests) behind an HTTP proxy, a special tunn
httpsAgent, // not necessary if using Basic or BearerToken authentication
355
350
proxy:false,
356
351
}),
357
-
version:'2020-01-28',
352
+
version:'2024-08-25',
358
353
httpsAgent,
359
354
proxy:false,
360
355
});
@@ -363,21 +358,21 @@ const assistant = new AssistantV1({
363
358
### Sending custom certificates
364
359
To send custom certificates as a security measure in your request, use the `cert`, `key`, and/or `ca` properties of the HTTPS Agent. See [this documentation](https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options) for more information about the options. Note that the entire contents of the file must be provided - not just the file name.
@@ -392,7 +387,7 @@ The HTTP client can be configured to disable SSL verification. **Note that this
392
387
To do this, set `disableSslVerification` to `true` in the service constructor and/or authenticator constructor, like below:
393
388
394
389
```js
395
-
constdiscovery=newDiscoveryV1({
390
+
constassistant=newAssistantV2({
396
391
serviceUrl:'<service_url>',
397
392
version:'<version-date>',
398
393
authenticator:newIamAuthenticator({ apikey:'<apikey>', disableSslVerification:true }), // this will disable SSL verification for requests to the token endpoint
@@ -407,8 +402,6 @@ To see all possible https agent configuration options go to this [link](https://
407
402
408
403
You can find links to the documentation at https://cloud.ibm.com/developer/watson/documentation. Find the service that you're interested in, click **API reference**, and then select the **Node** tab.
409
404
410
-
There are also auto-generated JSDocs available at http://watson-developer-cloud.github.io/node-sdk/master/
411
-
412
405
## Questions
413
406
414
407
If you have issues with the APIs or have a question about the Watson services, see [Stack Overflow](https://stackoverflow.com/questions/tagged/ibm-watson+node.js).
@@ -452,13 +445,13 @@ Use the [Assistant][assistant] service to determine the intent of a message.
452
445
Note: You must first create a workspace via IBM Cloud. See [the documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-index#about) for details.
@@ -727,21 +653,15 @@ See [CONTRIBUTING](https://github.com/watson-developer-cloud/node-sdk/blob/maste
727
653
We love to highlight cool open-source projects that use this SDK! If you'd like to get your project added to the list, feel free to make an issue linking us to it.
728
654
-[Watson Speech to Text Demo App](https://github.com/watson-developer-cloud/speech-to-text-nodejs)
Copy file name to clipboardExpand all lines: lib/recognize-stream.ts
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -86,6 +86,7 @@ class RecognizeStream extends Duplex {
86
86
* @param {string} [options.contentType] - The format (MIME type) of the audio
87
87
* @param {number} [options.customizationWeight] - Tell the service how much weight to give to words from the custom language model compared to those from the base model for the current request
88
88
* @param {number} [options.inactivityTimeout] - The time in seconds after which, if only silence (no speech) is detected in the audio, the connection is closed (default=30)
89
+
* @param {boolean} [options.interimResults] - If true, the service returns interim results as a stream of JSON SpeechRecognitionResults objects (default=false)
89
90
* @param {string[]} [options.keywords] - An array of keyword strings to spot in the audio
90
91
* @param {number} [options.keywordsThreshold] - A confidence value that is the lower bound for spotting a keyword
91
92
* @param {number} [options.maxAlternatives] - The maximum number of alternative transcripts that the service is to return (default=1)
@@ -104,6 +105,7 @@ class RecognizeStream extends Duplex {
104
105
* @param {boolean} [options.splitTranscriptAtPhraseEnd] - If `true`, directs the service to split the transcript into multiple final results based on semantic features of the input
105
106
* @param {number} [options.speechDetectorSensitivity] - The sensitivity of speech activity detection that the service is to perform
106
107
* @param {number} [options.backgroundAudioSuppression] - The level to which the service is to suppress background audio based on its volume to prevent it from being transcribed as speech
108
+
* @param {boolean} [params.lowLatency] - If `true` for next-generation `Multimedia` and `Telephony` models that support low latency, directs the service to produce results even more quickly than it usually does
107
109
* @constructor
108
110
*/
109
111
constructor(options: RecognizeStream.Options){
@@ -166,6 +168,7 @@ class RecognizeStream extends Duplex {
166
168
'timestamps',
167
169
'word_confidence',
168
170
'content-type',
171
+
'interim_results',
169
172
'keywords',
170
173
'keywords_threshold',
171
174
'max_alternatives',
@@ -179,6 +182,7 @@ class RecognizeStream extends Duplex {
0 commit comments