Skip to content

Commit 6bdb88e

Browse files
committed
Adding support for url playback/transcription, including in Mobile Safari
* Renamed recognizeStream()'s data param to file, now accepts a string for urls * New Mobile Safari-compatible example * Simplified several other examples
1 parent 070210f commit 6bdb88e

17 files changed

+941
-202
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,22 @@ Also note that Chrome requires https (with a few exceptions for localhost and su
7777

7878
Pipes results through a [FormatStream] by default, set `options.format=false` to disable.
7979

80-
Known issue: Firefox continues to display a microphone icon in the address bar after recording has ceased. This is a browser bug.
81-
8280

8381
### [`.recognizeFile({data, token})`](http://watson-developer-cloud.github.io/speech-javascript-sdk/master/module-watson-speech_speech-to-text_recognize-file.html) -> Stream
8482

8583
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)
8684
(such as from an `<input type="file"/>` or from an ajax request.)
8785

8886
Options:
89-
* `data`: a `Blob` or `File` instance.
87+
* `file`: a String URL or a `Blob` or `File` instance.
9088
* `play`: (optional, default=`false`) Attempt to also play the file locally while uploading it for transcription
9189
* Other options passed to [RecognizeStream]
9290
* Other options passed to [WritableElementStream] if `options.outputElement` is set
9391

9492
`play`requires that the browser support the format; most browsers support wav and ogg/opus, but not flac.)
95-
Will emit a `playback-error` on the RecognizeStream if playback fails.
96-
Playback will automatically stop when `.stop()` is called on the RecognizeStream.
93+
Will emit an `UNSUPPORTED_FORMAT` error on the RecognizeStream if playback fails.
94+
Playback will automatically stop when `.stop()` is called on the returned stream.
95+
For Mobile Safari compatibility, a URL must be provided, and `recognizeFile()` must be called in direct response to a user interaction (so the token must be pre-loaded).
9796

9897
Pipes results through a [TimingStream] by if `options.play=true`, set `options.realtime=false` to disable.
9998

@@ -109,6 +108,7 @@ There have been a few breaking changes in recent releases:
109108
* Changed `playFile` option of `recognizeBlob()` to just `play`, corrected default
110109
* Changed format of objects emitted in objectMode to exactly match what service sends. Added `ResultStrean` class and `extract_results` option to enable older behavior.
111110
* Changed `playback-error` event to just `error` when recognizing and playing a file. Check for `error.name == 'UNSUPPORTED_FORMAT'` to identify playback errors
111+
* Renamed `recognizeFile()`'s `data` option to `file` because it now may be a URL. Using a URL enables faster playback and mobile Safari support
112112

113113
See [CHANGELOG.md](CHANGELOG.md) for a complete list of changes.
114114

0 commit comments

Comments
 (0)