Skip to content

Commit d40dab5

Browse files
committed
re-enabling speaker stream & timing stream combo, cleanup
1 parent efb598a commit d40dab5

File tree

5 files changed

+5338
-17
lines changed

5 files changed

+5338
-17
lines changed

dist/watson-speech.js

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

speech-to-text/recognize-file.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ var SpeakerStream = require('./speaker-stream');
3838
* @param {Blob|File} options.data - the raw audio data as a Blob or File instance
3939
* @param {Boolean} [options.play=false] - If a file is set, play it locally as it's being uploaded
4040
* @param {Boolena} [options.format=true] - pipe the text through a {FormatStream} which performs light formatting. Also controls smart_formatting option unless explicitly set.
41-
* @param {Boolena} [options.realtime=options.play] - pipe the text through a {TimingStream} which slows the output down to real-time to match the audio playback. Not currently compatible with resultsBySpeaker option.
41+
* @param {Boolena} [options.realtime=options.play] - pipe the text through a {TimingStream} which slows the output down to real-time to match the audio playback.
4242
* @param {String|DOMElement} [options.outputElement] pipe the text to a WriteableElementStream targeting the specified element. Also defaults objectMode to true to enable interim results.
4343
* @param {Boolean} [options.extractResults=false] pipe results through a ResultExtractor stream to simplify the objects. (Default behavior before v0.22) Automatically enables objectMode.
44-
* @param {Boolean} [options.resultsBySpeaker=false] pipe results through a SpeakerStream. Causes each data event to include multiple results, each with a speaker field. Automatically enables objectMode and speaker_labels. Automatically disables the realtime option due to incompatibilities. Adds some delay to processing.
44+
* @param {Boolean} [options.resultsBySpeaker=false] pipe results through a SpeakerStream. Causes each data event to include multiple results, each with a speaker field. Automatically enables objectMode and speaker_labels. Adds some delay to processing.
4545
*
4646
* @returns {RecognizeStream|SpeakerStream|FormatStream|ResultStream|TimingStream}
4747
*/
@@ -62,7 +62,6 @@ module.exports = function recognizeFile(options) { // eslint-disable-line comple
6262
if (options.resultsBySpeaker) {
6363
options.objectMode = true;
6464
options.speaker_labels = true;
65-
options.realtime = false;
6665
}
6766

6867
// default format to true (capitals and periods)
@@ -109,6 +108,7 @@ module.exports = function recognizeFile(options) { // eslint-disable-line comple
109108
streams.push(stream);
110109
}
111110

111+
// note: the format stream should come after the speaker stream to format sentences correctly
112112
if (options.format) {
113113
stream = stream.pipe(new FormatStream(options));
114114
streams.push(stream);

speech-to-text/speaker-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,8 @@ SpeakerStream.prototype._transform = function(data, encoding, next) {
224224
}
225225
if (Array.isArray(data.speaker_labels)) {
226226
this.handleSpeakerLabels(data);
227+
this.process();
227228
}
228-
this.process();
229229
next();
230230
};
231231

0 commit comments

Comments
 (0)