Skip to content

Commit 31f34f3

Browse files
committed
don't stop transcription for playback errors
1 parent df1660b commit 31f34f3

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
### v0.28.1
4+
* Fix regression introduced in v0.23 with playback-error change - transcription now continues after a playback error.
5+
36
### v0.28.0
47
* Significantly simplified TimingStream, fixing one bug in the process
58

dist/watson-speech.js

Lines changed: 21 additions & 1 deletion
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: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,27 @@ module.exports = function recognizeFile(options) { // eslint-disable-line comple
116116
recognizeStream.on('stop', player.stop.bind(player));
117117
recognizeStream.on('error', player.stop.bind(player));
118118
}).catch(function(err) {
119+
120+
// Node.js automatically unpipes any source stream(s) when an error is emitted (on the assumption that the previous stream's output caused the error.)
121+
// In this case, we don't want that behavior - a playback error should not stop the transcription
122+
// So, we have to:
123+
// 1. find the source streams
124+
// 2. emit the error (causing the automatic unpipe)
125+
// 3. re-pipe the source streams
126+
127+
var sources = streams.filter(function(s) {
128+
return s._readableState
129+
&& s._readableState.pipes
130+
&& (s._readableState.pipes === stream
131+
|| (Array.isArray(s._readableState.pipes) && s._readableState.pipes.indexOf(stream) !== -1)
132+
);
133+
});
134+
119135
stream.emit('error', err);
136+
137+
sources.forEach(function(s) {
138+
s.pipe(stream);
139+
});
120140
});
121141
}
122142

0 commit comments

Comments
 (0)