Skip to content

Commit 687f694

Browse files
committed
added WritableElementStream for basic html output, updated examples
1 parent baeafe3 commit 687f694

30 files changed

+1045
-763
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ insert_final_newline = true
1010

1111
# Matches multiple files with brace expansion notation
1212
# Set default charset
13-
[*.{js,json,ymo}]
13+
[*.{js,json,ymo,html,htm}]
1414
charset = utf-8
1515
indent_style = space
1616
indent_size = 2

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,16 @@ Options:
4444

4545
### `.getVoices()` -> Promise
4646

47-
Returns a promise that resolves to an array of objects representing the available voices. Example:
48-
49-
```js
50-
[{
51-
"name": "en-US_MichaelVoice",
52-
"language": "en-US",
53-
"customizable": true,
54-
"gender": "male",
55-
"url": "https://stream.watsonplatform.net/text-to-speech/api/v1/voices/en-US_MichaelVoice",
56-
"description": "Michael: American English male voice."
57-
},
58-
//...
59-
]
60-
```
47+
Returns a promise that resolves to an array of objects containing the name, language, gender, and other details for each voice.
48+
49+
Requires[window.fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), a [pollyfill](https://www.npmjs.com/package/whatwg-fetch) for IE/Edge and older Chrome/Firefox.
6150

6251
## `WatsonSpeech.SpeechToText`
6352

6453

6554
### `.recognizeMicrophone({token})` -> `RecognizeStream`
6655

67-
Options: No direct options, all provided options are passed to MicrophoneStream and RecognizeStream
56+
Options: No direct options, all provided options are passed to MicrophoneStream and RecognizeStream, and WritableElementStream if `options.outputElement` is set
6857

6958
Requires the `getUserMedia` API, so limited browser compatibility (see http://caniuse.com/#search=getusermedia)
7059
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
@@ -88,6 +77,7 @@ Because of these limitations, it may be preferable to instead fetch the audio vi
8877
Options:
8978
* `element`: an `<audio>` or `<video>` element (could be generated pragmatically, e.g. `new Audio()`)
9079
* Other options passed to MediaElementAudioStream and RecognizeStream
80+
* Other options passed to WritableElementStream if `options.outputElement` is set
9181

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

@@ -101,6 +91,7 @@ Options:
10191
* `data`: a `Blob` (or `File`) instance.
10292
* `play`: (optional, default=`false`) Attempt to also play the file locally while uploading it for transcription
10393
* Other options passed to RecognizeStream
94+
* Other options passed to WritableElementStream if `options.outputElement` is set
10495

10596
`play`requires that the browser support the format; most browsers support wav and ogg/opus, but not flac.)
10697
Will emit a `playback-error` on the RecognizeStream if playback fails.
@@ -152,9 +143,17 @@ Inherits `.promise()` from the `RecognizeStream`.
152143

153144
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.
154145

146+
### Class `WritableElementStream()`
147+
148+
Accepts input from `RecognizeStream()` and friends, writes text to supplied `outputElement`.
149+
155150

156151
## Changelog
157152

153+
### v0.10
154+
* Added ability to write text directly to targetElement, updated examples to use this
155+
* converted examples from jQuery to vanilla JS + fetch pollyfill
156+
158157
### v0.9
159158
* Added basic text to speech support
160159

@@ -187,3 +186,5 @@ For use with `.recognizeBlob({play: true})` - slows the results down to match th
187186
* consider renaming recognizeBlob to recognizeFile to make the usage more obvious
188187
* consider an `interim` event for recognize/format/timing streams to avoid objectMode (in most cases)
189188
* ajax / playFile demo
189+
* support a "hard" stop that prevents any further data events, even for already uploaded audio, ensure timing stream also impliments this.
190+
* handle pause/resume in media element streams - perhaps just stop and then create a new stream on resume

0 commit comments

Comments
 (0)