File tree Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Expand file tree Collapse file tree 3 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,12 @@ module.exports = function recognizeFile(options) { // eslint-disable-line comple
150
150
}
151
151
}
152
152
153
+ // expose the original stream to for debugging (and to support the JSON tab on the STT demo)
154
+ if ( stream !== recognizeStream ) {
155
+ stream . recognizeStream = recognizeStream ;
156
+ }
157
+
158
+
153
159
return stream ;
154
160
} ;
155
161
Original file line number Diff line number Diff line change @@ -178,11 +178,13 @@ module.exports = function recognizeMicrophone(options) {
178
178
}
179
179
} ) ;
180
180
181
- // add a stop button to whatever the final stream ends up being
182
181
if ( stream !== recognizeStream ) {
182
+ // add a stop button to whatever the final stream ends up being
183
183
stream . stop = recognizeStream . stop . bind ( recognizeStream ) ;
184
- }
185
184
185
+ // expose the original stream to for debugging (and to support the JSON tab on the STT demo)
186
+ stream . recognizeStream = recognizeStream ;
187
+ }
186
188
187
189
return stream ;
188
190
} ;
Original file line number Diff line number Diff line change @@ -285,6 +285,14 @@ RecognizeStream.prototype.initialize = function() {
285
285
}
286
286
287
287
socket . onmessage = function ( frame ) {
288
+ /**
289
+ * Emit any messages received over the wire, mainly used for debugging.
290
+ *
291
+ * @event RecognizeStream#message
292
+ * @param {Object } message - frame object with a data attribute that's either a string or a Buffer/TypedArray
293
+ */
294
+ this . emit ( 'message' , frame ) ;
295
+
288
296
if ( typeof frame . data !== 'string' ) {
289
297
return emitError ( 'Unexpected binary data received from server' , frame ) ;
290
298
}
@@ -336,14 +344,20 @@ RecognizeStream.prototype.initialize = function() {
336
344
337
345
RecognizeStream . prototype . sendJSON = function sendJSON ( msg ) {
338
346
/**
347
+ * Emits any JSON object sent to the service from the client. Mainly used for debugging.
339
348
* @event RecognizeStream#send-json
340
- * @param {Object } msg - the raw JSON sent to Watson - sometimes useful for debugging
349
+ * @param {Object } msg
341
350
*/
342
351
this . emit ( 'send-json' , msg ) ;
343
352
return this . socket . send ( JSON . stringify ( msg ) ) ;
344
353
} ;
345
354
346
355
RecognizeStream . prototype . sendData = function sendData ( data ) {
356
+ /**
357
+ * Emits any Binary object sent to the service from the client. Mainly used for debugging.
358
+ * @event RecognizeStream#send-data
359
+ * @param {Object } msg
360
+ */
347
361
this . emit ( 'send-data' , data ) ;
348
362
return this . socket . send ( data ) ;
349
363
} ;
You can’t perform that action at this time.
0 commit comments