Skip to content

Commit 7c58312

Browse files
committed
doc and example improvements
1 parent 860eb3b commit 7c58312

File tree

3 files changed

+26
-15
lines changed

3 files changed

+26
-15
lines changed

README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Options: No direct options, all provided options are passed to MicrophoneStream
3636
Requires the `getUserMedia` API, so limited browser compatibility (see http://caniuse.com/#search=getusermedia)
3737
Also note that Chrome requires https (with a few exceptions for localhost and such) - see https://www.chromium.org/Home/chromium-security/prefer-secure-origins-for-powerful-new-features
3838

39+
Pipes results through a `{FormatStream}` by default, set `options.format=false` to disable.
40+
3941
### `.recognizeElement({element, token})` -> `RecognizeStream`
4042

4143
Options:
@@ -44,19 +46,24 @@ Options:
4446

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

47-
Will automatically call `.play()` the `element`. Calling `.stop()` on the returned RecognizeStream 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`.
50+
51+
Pipes results through a `{FormatStream}` by default, set `options.format=false` to disable.
4852

4953
### `.recognizeBlob({data, token})` -> `RecognizeStream`
5054

5155
Options:
5256
* `data`: a `Blob` (or `File`) instance.
53-
* `playFile`: (optional, default=`false`) Attempt to also play the file locally while uploading it for transcription
57+
* `play`: (optional, default=`false`) Attempt to also play the file locally while uploading it for transcription
5458
* Other options passed to RecognizeStream
5559

56-
`playFile`requires that the browser support the format; most browsers support wav and ogg/opus, but not flac.)
60+
`play`requires that the browser support the format; most browsers support wav and ogg/opus, but not flac.)
5761
Will emit a `playback-error` on the RecognizeStream if playback fails.
5862
Playback will automatically stop when `.stop()` is called on the RecognizeStream.
5963

64+
Pipes results through a `{TimingStream}` by if `options.play=true`, set `options.realtime=false` to disable.
65+
66+
Pipes results through a `{FormatStream}` by default, set `options.format=false` to disable.
6067

6168
### Class `RecognizeStream()`
6269

@@ -99,25 +106,27 @@ Inherits `.promise()` and `.stop()` methods and `result` event from the `Recogni
99106

100107
### Class `TimingStream()`
101108

102-
For use with `.recognizeBlob({playFile: true})` - slows the results down to match the audio. Pipe in the `RecognizeStream` (or `FormatStream`) and listen for results as usual.
109+
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.
103110

104111
Inherits `.stop()` method and `result` event from the `RecognizeStream`.
105112

106113

107114
## Changelog
108115

109116
### v0.7
110-
* Changed playFile option of recognizeBlob to play to match docs
111-
* Added options.format to recognize* to pipe text through a FormatStream (default: true)
112-
* Added close and end events to TimingStream
113-
117+
* Changed `playFile` option of `recognizeBlob()` to just `play`, corrected default
118+
* Added `options.format=true` to `recognize*()` to pipe text through a FormatStream
119+
* Added `options.realtime=options.play` to `recognizeBlob()` to automatically pipe results through a TimingStream when playing locally
120+
* Added `close` and `end` events to TimingStream
121+
* Added `delay` option to `TimingStream`
122+
* Moved compiled binary to GitHub Releases (in addition to uncompiled source on npm).
123+
* Misc. doc and internal improvements
114124

115125
## todo
116126

117-
* Fix bugs around `.stop()
118127
* Solidify API
119128
* support objectMode instead of having random events
120-
* add text-to-speech support
129+
* add text-to-speech support
121130
* add an example that includes alternatives and word confidence scores
122131
* enable eslint
123132
* break components into standalone npm modules where it makes sense

examples/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"description": "Example app showing the IBM Watson Speech To Text browser library in action.",
55
"main": "token-server.js",
66
"scripts": {
7-
"start": "node token-server.js"
7+
"start": "node token-server.js",
8+
89
},
910
"dependencies": {
1011
"express": "^4.13.3",

examples/readme.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ Prerequisite
1717
Setup
1818
-----
1919

20-
1. `cd` into the `examples/` directory and run `npm install` to grab dependencies
21-
2. edit `token-server.js` to include your service credentials
22-
3. run `npm start`
23-
4. Open your browser to http://localhost:3000/ to see the examples.
20+
1. Run `npm install; npm run build` in the project root to generate a `dist/watson-speech.js` file (or grab a copy from GitHub releases and drop it into `examples/public/`)
21+
2. `cd` into the `examples/` directory and run `npm install` to grab dependencies
22+
3. edit `token-server.js` to include your service credentials
23+
4. run `npm start`
24+
5. Open your browser to http://localhost:3000/ to see the examples.
2425

2526

2627
Notes

0 commit comments

Comments
 (0)