Skip to content

Commit 13cb6f9

Browse files
committed
cleanup playback errors, automatically stop playback for recognizestream errors
1 parent a52705f commit 13cb6f9

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

CHANGELOG.md

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

3+
### v0.23.0
4+
* Changed file player error.name from `UNRECOGNIZED_FORMAT` to `UNSUPPORTED_FORMAT`
5+
(There are now two potential errors with this name: the file is recognized but the browser cannot play it, and the file type is not recognized.)
6+
* Changed the `playback-error` event to just `error`
7+
* Automatically stop file playback in the event of a RecognizeStream error
38

49
### v0.22.0
510
* Breaking: RecognizeStream now emits the original JSON message rather than the extracted results objects.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ There have been a few breaking changes in recent releases:
111111
* renamed `recognizeBlob` to `recognizeFile` to make the primary usage more apparent
112112
* Changed `playFile` option of `recognizeBlob()` to just `play`, corrected default
113113
* Changed format of objects emitted in objectMode to exactly match what service sends. Added `ResultExtractor` class and `extract_results` option to enable older behavior.
114+
* Changed `playback-error` event to just `error` when recognizing and playing a file. Check for `error.name == 'UNSUPPORTED_FORMAT'` to identify playback errors
114115

115116
See [CHANGELOG.md](CHANGELOG.md) for a complete list of changes.
116117

speech-to-text/file-player.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ function getContentTypeFromFile(file) {
1818
resolve(ct);
1919
} else {
2020
var err = new Error('Unable to determine content type from file header; only wav, flac, and ogg/opus are supported.');
21-
err.name = 'UNRECOGNIZED_FORMAT';
21+
err.name = 'UNSUPPORTED_FORMAT';
2222
reject(err);
2323
}
2424
};

speech-to-text/recognize-file.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ module.exports = function recognizeFile(options) { // eslint-disable-line comple
9494
if (options.play) {
9595
FilePlayer.playFile(options.data).then(function(player) {
9696
recognizeStream.on('stop', player.stop.bind(player));
97+
recognizeStream.on('error', player.stop.bind(player));
9798
}).catch(function(err) {
98-
stream.emit('playback-error', err);
99+
stream.emit('error', err);
99100
});
100101
}
101102

0 commit comments

Comments
 (0)