Skip to content

Commit d2ae95b

Browse files
committed
some improvements.. might be broken right now
1 parent abf765c commit d2ae95b

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

dist/watson-speech.js

Lines changed: 22 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

speech-to-text/format-stream.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var clone = require('clone');
1414
* @param opts
1515
* @param opts.model - some models / languages need special handling
1616
* @param [opts.hesitation='\u2026'] - what to put down for a "hesitation" event, defaults to an ellipsis (...)
17+
* @param {Boolean} [options.objectMode=false] - emit `result` objects instead of string Buffers for the `data` events.
1718
* @constructor
1819
*/
1920
function FormatStream(opts) {

speech-to-text/recognize-stream.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var QUERY_PARAMS_ALLOWED = ['model', 'watson-token']; //, 'X-Watson-Learning-Opt
5454
* @constructor
5555
*/
5656
function RecognizeStream(options) {
57-
Duplex.call(this, {readableObjectMode: options && (options.objectMode)});
57+
Duplex.call(this, {readableObjectMode: options && (options.objectMode || options.readableObjectMode)});
5858
this.options = options;
5959
this.listening = false;
6060
this.initialized = false;
@@ -223,9 +223,9 @@ RecognizeStream.prototype.initialize = function () {
223223
* @param {String} transcript
224224
*/
225225
if (options.objectMode) {
226-
self.push(result); // this is the "data" event that can be easily piped to other streams
226+
self.push(result);
227227
} else {
228-
self.push(result.alternatives[0].transcript, 'utf8'); // this is the "data" event that can be easily piped to other streams
228+
self.push(result.alternatives[0].transcript, 'utf8');
229229
}
230230

231231
}

speech-to-text/timing-stream.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ var clone = require('clone');
1212
* @param {Object} opts
1313
* @param {*} [opts.emitAtt=TimingStream.START] - set to TimingStream.END to only emit text that has been completely spoken.
1414
* @param {Number} [opts.delay=0] - Additional delay (in seconds) to apply before emitting words, useful for precise syncing to audio tracks. May be negative
15+
* @param {Boolean} [options.objectMode=false] - emit `result` objects instead of string Buffers for the `data` events.
1516
* @constructor
1617
*/
1718
function TimingStream(opts) {
1819
this.opts = util._extend({
1920
emitAt: TimingStream.START,
2021
delay: 0,
21-
allowHalfOpen: true // keep the readable side open after the source closes
22+
allowHalfOpen: true, // keep the readable side open after the source closes
23+
objectMode: false
2224
}, opts);
2325
Duplex.call(this, opts);
2426

0 commit comments

Comments
 (0)