Skip to content

Commit 0a62b2b

Browse files
committed
it all works! - prep'ing for release
1 parent fc2e756 commit 0a62b2b

File tree

10 files changed

+57
-71
lines changed

10 files changed

+57
-71
lines changed

README.md

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Options:
4646

4747
Requires that the browser support MediaElement and whatever audio codec is used in your media file.
4848

49-
Will automatically call `.play()` the `element`, set `options.autoplay=false` to disable. Calling `.stop()` on the returned stream will automatically call `.stop()` on the `element`.
49+
Will automatically call `.play()` the `element`, set `options.autoPlay=false` to disable. Calling `.stop()` on the returned stream will automatically call `.stop()` on the `element`.
5050

5151
Pipes results through a `{FormatStream}` by default, set `options.format=false` to disable.
5252

@@ -85,13 +85,12 @@ See speech-to-text/recognize-stream.js for other options.
8585
Standard `close` event will fire once the underlying websocket is closed and `end` once all of the data is consumed.
8686

8787
#### Events
88-
In addition to the standard [Node.js stream events](https://nodejs.org/api/stream.html), the following events are fired:
88+
Follows standard [Node.js stream events](https://nodejs.org/api/stream.html), in particular:
8989

90-
* `result`: an individual result object from the results array.
91-
May include final or interim transcription, alternatives, word timing, confidence scores, etc. depending on passed in options.
92-
Note: Listening for `result` will automatically put the stream into flowing mode.
90+
* `data`: emits either final Strings or final/interim result objects depending on if the stream is in objectMode
91+
* `end`: emitted once all data has been consumed.
9392

94-
(Note: there are several other events, but they are intended for internal usage)
93+
(Note: there are several custom events, but they are deprecated or intended for internal usage)
9594

9695
### Class `FormatStream()`
9796

@@ -101,18 +100,20 @@ Pipe a `RecognizeStream` to a format stream, and the resulting text and `results
101100
* Fix any "cruft" in the transcription
102101
* A few other tweaks for asian languages and such.
103102

104-
Inherits `.promise()` and `.stop()` methods and `result` event from the `RecognizeStream`.
103+
Inherits `.promise()` from the `RecognizeStream`.
105104

106105

107106
### Class `TimingStream()`
108107

109108
For use with `.recognizeBlob({play: true})` - slows the results down to match the audio. Pipe in the `RecognizeStream` (or `FormatStream`) and listen for results as usual.
110109

111-
Inherits `.stop()` method and `result` event from the `RecognizeStream`.
112-
113110

114111
## Changelog
115112

113+
### v0.8
114+
* deprecated `result` events in favor of `objectMode`.
115+
* renamed the `autoplay` option to `autoPlay` on `recognizeElement()` (capital P)
116+
116117
### v0.7
117118
* Changed `playFile` option of `recognizeBlob()` to just `play`, corrected default
118119
* Added `options.format=true` to `recognize*()` to pipe text through a FormatStream
@@ -125,21 +126,16 @@ Inherits `.stop()` method and `result` event from the `RecognizeStream`.
125126
## todo
126127

127128
* Solidify API
128-
* support objectMode instead of having random events
129-
* add text-to-speech support
129+
* add text-to-speech support - may require service improvements
130130
* add an example that includes alternatives and word confidence scores
131-
* enable eslint
131+
* enable eslint - https://github.ibm.com/fed/javascript-style-guides
132132
* break components into standalone npm modules where it makes sense
133-
* record which shim/pollyfills would be useful to extend partial support to older browsers (Promise, etc.)
133+
* record which shim/pollyfills would be useful to extend partial support to older browsers (Promise, Object.assign, etc.)
134134
* run integration tests on travis (fall back to offline server for pull requests)
135135
* more tests in general
136136
* update node-sdk to use current version of this lib's RecognizeStream (and also provide the FormatStream + anything else that might be handy)
137+
* move `result` and `results` events to node wrapper (along with the deprecation notice)
137138
* improve docs
138139
* consider a wrapper to match https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
139-
140-
141-
recognizeBlob -> recognizeFile (?)
142-
objectMode
143-
move timing/format stream.stop to wrapper methods
144-
test promise with objectmode
145-
consider interim event for recognize/format/timing streams
140+
* consider renaming recognizeBlob to recognizeFile to make the usage more obvious
141+
* consider an `interim` event for recognize/format/timing streams to avoid objectMode (in most cases)

dist/watson-speech.js

Lines changed: 35 additions & 40 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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,6 @@ FormatStream.prototype.formatResult = function formatResult(result, encoding, ne
116116
next();
117117
};
118118

119-
FormatStream.prototype.promise = require('./promise');
120-
121-
FormatStream.prototype.stop = function(){}; // usually overwritten during the `pipe` event
119+
FormatStream.prototype.promise = require('./to-promise');
122120

123121
module.exports = FormatStream;

speech-to-text/recognize-blob.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ module.exports = function recognizeBlob(options) {
5959
if (realtime) {
6060
stream = stream.pipe(new TimingStream(options));
6161
}
62+
stream.stop = recognizeStream.stop.bind(recognizeStream);
6263

6364
if (options.play) {
6465
FilePlayer.playFile(options.data).then(function (player) {

speech-to-text/recognize-element.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module.exports = function recognizeElement(options) {
5656

5757
if (options.format !== false) {
5858
stream = stream.pipe(new FormatStream(options));
59+
stream.stop = recognizeStream.stop.bind(recognizeStream);
5960
}
6061

6162
recognizeStream.on('stop', sourceStream.stop.bind(sourceStream));

speech-to-text/recognize-microphone.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ module.exports = function recognizeMicrophone(options) {
6363
var stream = recognizeStream;
6464
if (options.format !== false) {
6565
stream = stream.pipe(new FormatStream(options));
66+
stream.stop = recognizeStream.stop.bind(recognizeStream);
6667
}
6768

6869
return stream;

speech-to-text/recognize-stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ RecognizeStream.prototype.finish = function finish() {
324324
}
325325
};
326326

327-
RecognizeStream.prototype.promise = require('./promise');
327+
RecognizeStream.prototype.promise = require('./to-promise');
328328

329329

330330
RecognizeStream.getContentType = function (buffer) {

speech-to-text/timing-stream.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ function TimingStream(opts) {
3333

3434
var self = this;
3535
this.on('pipe', function(source) {
36-
if(source.stop) {
37-
self.stop = source.stop.bind(source);
38-
}
3936
source.on('end', function() {
4037
self.sourceEnded = true; // todo: see if there's anything built-in that does this for us
4138
});
@@ -223,7 +220,4 @@ TimingStream.prototype.handleResult = function handleResult(result) {
223220
this.tick();
224221
};
225222

226-
TimingStream.prototype.stop = function(){}; // usually overwritten during the `pipe` event
227-
228-
229223
module.exports = TimingStream;
File renamed without changes.

test/resources/integration_test_server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var fs = require('fs');
22
var watson = require('watson-developer-cloud');
33

4-
var AUTH_FILE = __dirname + '/auth.json';
4+
var AUTH_FILE = __dirname + '/stt-auth.json';
55

66
if (!fs.existsSync(AUTH_FILE)) {
77
console.error('Missing required test/resources/auth.json for integration test - see https://github.com/watson-developer-cloud/node-sdk#getting-the-service-credentials');

0 commit comments

Comments
 (0)