Skip to content

Commit 062179d

Browse files
committed
docs: add jsdocs comments to the synthesize-stream class
1 parent 2c77a32 commit 062179d

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

lib/recognize-stream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ interface RecognizeStream extends Duplex {
5454
}
5555

5656
/**
57-
* pipe()-able Node.js Readable/Writeable stream - accepts binary audio and emits text in it's `data` events.
57+
* pipe()-able Node.js Readable/Writeable stream - accepts binary audio and emits text in its `data` events.
5858
* Also emits `results` events with interim results and other data.
5959
*
6060
* Cannot be instantiated directly, instead created by calling #recognizeUsingWebSocket()

lib/synthesize-stream.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ interface SynthesizeStream extends Readable {
4040
_readableState;
4141
}
4242

43+
/**
44+
* pipe()-able Node.js Readable stream - accepts text in the constructor and emits binary audio data in its 'message' events
45+
*
46+
* Cannot be instantiated directly, instead created by calling #synthesizeUsingWebSocket()
47+
*
48+
* Uses WebSockets under the hood.
49+
* @param {Object} options
50+
* @constructor
51+
*/
4352
class SynthesizeStream extends Readable {
4453

4554
static WEBSOCKET_CONNECTION_ERROR: string = 'WebSocket connection error';
@@ -49,6 +58,31 @@ class SynthesizeStream extends Readable {
4958
private initialized: boolean;
5059
private authenticated: boolean;
5160

61+
62+
/**
63+
* pipe()-able Node.js Readable stream - accepts text and emits binary audio data in its 'message' events
64+
*
65+
* Uses WebSockets under the hood.
66+
*
67+
*
68+
* Note that the WebSocket connection is not established until the first chunk of data is recieved. This allows for IAM token request management by the SDK.
69+
*
70+
* @param {Object} options
71+
* @param {String} options.text - The text that us to be synthesized. Provide plain text or text that is annotated with SSML. SSML input can include the SSML <mark> element. Pass a maximum of 5 KB of text.
72+
* @param {String} options.accept - The requested audio format (MIME type) of the audio.
73+
* @param {String[]} [options.timings] - An array that specifies whether the service is to return word timing information for all strings of the input text
74+
* @param {String} [options.voice='en-US_MichaelVoice'] - The voice that is to be used for the synthesis.
75+
* @param {String} [options.customization_id] - The customization ID (GUID) of a custom voice model that is to be used for the synthesis.
76+
* @param {String} [options.url='wss://stream.watsonplatform.net/speech-to-text/api'] base URL for service
77+
* @param {String} [options.watson-token] - Auth token
78+
* @param {Object} [options.headers] - Only works in Node.js, not in browsers. Allows for custom headers to be set, including an Authorization header (preventing the need for auth tokens)
79+
* @param {Boolean} [options.x-watson-learning-opt-out=false] - set to true to opt-out of allowing Watson to use this request to improve it's services
80+
* @param {String} [options.x-watson-metadata] - Associates a customer ID with data that is passed over the connection.
81+
* @param {IamTokenManagerV1} [options.token_manager] - Token manager for authenticating with IAM
82+
* @param {Boolean} [options.rejectUnauthorized] - If true, disable SSL verification for the WebSocket connection
83+
*
84+
* @constructor
85+
*/
5286
constructor(options) {
5387
super(options);
5488
this.options = options;
@@ -144,6 +178,15 @@ class SynthesizeStream extends Readable {
144178
});
145179
}
146180

181+
/**
182+
* This function retrieves an IAM access token and stores it in the
183+
* request header before calling the callback function, which will
184+
* execute the next iteration of `_read()`
185+
*
186+
*
187+
* @private
188+
* @param {Function} callback
189+
*/
147190
setAuthorizationHeaderToken(callback) {
148191
if (!this.authenticated) {
149192
this.options.token_manager.getToken((err, token) => {

0 commit comments

Comments
 (0)