Skip to content

Commit 8cd4e8b

Browse files
committed
Renamed recognizeBlob to recognizeFile, added an ajax example
also more tests and some testing tweaks
1 parent 92e4001 commit 8cd4e8b

15 files changed

+413
-174
lines changed

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ This method has some limitations:
7272
* it transcribes the audio as it is heard, so pausing or skipping will affect the transcription
7373
* audio that is paused for too long will cause the socket to time out and disconnect, preventing further transcription (without setting things up again)
7474

75-
Because of these limitations, it may be preferable to instead fetch the audio via ajax and then pass it the `recognizeBlob()` API in some situations.
75+
Because of these limitations, it may be preferable to instead fetch the audio via ajax and then pass it the `recognizeFile()` API in some situations.
7676

7777
Options:
7878
* `element`: an `<audio>` or `<video>` element (could be generated pragmatically, e.g. `new Audio()`)
@@ -85,10 +85,13 @@ Will automatically call `.play()` the `element`, set `options.autoPlay=false` to
8585

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

88-
### `.recognizeBlob({data, token})` -> `RecognizeStream`
88+
### `.recognizeFile({data, token})` -> `RecognizeStream`
89+
90+
Can recognize and optionally attempt to play a [File](https://developer.mozilla.org/en-US/docs/Web/API/File) or [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)
91+
(such as from an `<input type="file"/>` or from an ajax request.)
8992

9093
Options:
91-
* `data`: a `Blob` (or `File`) instance.
94+
* `data`: a `Blob` or `File` instance.
9295
* `play`: (optional, default=`false`) Attempt to also play the file locally while uploading it for transcription
9396
* Other options passed to RecognizeStream
9497
* Other options passed to WritableElementStream if `options.outputElement` is set
@@ -141,7 +144,9 @@ Inherits `.promise()` from the `RecognizeStream`.
141144

142145
### Class `TimingStream()`
143146

144-
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.
147+
For use with `.recognizeFile({play: true})` - slows the results down to match the audio. Pipe in the `RecognizeStream` (or `FormatStream`) and listen for results as usual.
148+
149+
Inherits `.promise()` from the `RecognizeStream`.
145150

146151
### Class `WritableElementStream()`
147152

@@ -150,6 +155,13 @@ Accepts input from `RecognizeStream()` and friends, writes text to supplied `out
150155

151156
## Changelog
152157

158+
### v0.11
159+
* renamed `recognizeBlob` to `recognizeFile` to make the primary usage more apparent
160+
* Added support for `<input>` and `<textarea>` elements when using the `targetElement` option (or a `WritableElementStream`)
161+
* For objectMode, changed defaults for `word_confidence` to `false`, `alternatives` to `1`, and `timing` to off unless required for `realtime` option.
162+
* Fixed bug with calling `.promise()` on `objectMode` streams
163+
* Fixed bug with calling `.promise()` on `recognizeFile({play: true})`
164+
153165
### v0.10
154166
* Added ability to write text directly to targetElement, updated examples to use this
155167
* converted examples from jQuery to vanilla JS (w/ fetch pollyfill when necessary)
@@ -174,7 +186,6 @@ Accepts input from `RecognizeStream()` and friends, writes text to supplied `out
174186
## todo
175187

176188
* Solidify API
177-
* add an ajax / recognizeBlob example and then use it for stt sample app
178189
* enable eslint - https://github.ibm.com/fed/javascript-style-guides
179190
* break components into standalone npm modules where it makes sense
180191
* record which shim/pollyfills would be useful to extend partial support to older browsers (Promise, fetch, etc.)
@@ -185,8 +196,8 @@ Accepts input from `RecognizeStream()` and friends, writes text to supplied `out
185196
* move `result` and `results` events to node wrapper (along with the deprecation notice)
186197
* improve docs
187198
* consider a wrapper to match https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html
188-
* consider renaming recognizeBlob to recognizeFile to make the usage more obvious
189199
* support a "hard" stop that prevents any further data events, even for already uploaded audio, ensure timing stream also implements this.
190200
* handle pause/resume in media element streams - perhaps just stop and then create a new stream on resume, using the same token
191201
* consider moving STT core to standalone module
192202
* look for bug where single-word final results may omit word confidence (possibly due to FormatStream?)
203+
* fix bug where TimingStream shows words slightly before they're spoken

0 commit comments

Comments
 (0)