You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Speaks the supplied text through an automatically-created `<audio>` element.
47
47
Currently limited to text that can fit within a GET URL (this is particularly an issue on [Internet Explorer before Windows 10](http://stackoverflow.com/questions/32267442/url-length-limitation-of-microsoft-edge)
@@ -53,89 +53,42 @@ Options:
53
53
* autoPlay - set to false to prevent the audio from automatically playing
*`keepMic`: if true, preserves the MicrophoneStream for subsequent calls, preventing additional permissions requests in Firefox
63
-
* Other options passed to MediaElementAudioStream and RecognizeStream
64
-
* Other options passed to WritableElementStream if `options.outputElement` is set
63
+
* Other options passed to [RecognizeStream]
64
+
* Other options passed to [WritableElementStream] if `options.outputElement` is set
65
65
66
66
Requires the `getUserMedia` API, so limited browser compatibility (see http://caniuse.com/#search=getusermedia)
67
67
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
68
68
69
-
Pipes results through a `{FormatStream}` by default, set `options.format=false` to disable.
69
+
Pipes results through a [FormatStream] by default, set `options.format=false` to disable.
70
70
71
71
Known issue: Firefox continues to display a microphone icon in the address bar after recording has ceased. This is a browser bug.
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)
76
77
(such as from an `<input type="file"/>` or from an ajax request.)
77
78
78
79
Options:
79
80
*`data`: a `Blob` or `File` instance.
80
81
*`play`: (optional, default=`false`) Attempt to also play the file locally while uploading it for transcription
81
-
* Other options passed to RecognizeStream
82
-
* Other options passed to WritableElementStream if `options.outputElement` is set
82
+
* Other options passed to [RecognizeStream]
83
+
* Other options passed to [WritableElementStream] if `options.outputElement` is set
83
84
84
85
`play`requires that the browser support the format; most browsers support wav and ogg/opus, but not flac.)
85
86
Will emit a `playback-error` on the RecognizeStream if playback fails.
86
87
Playback will automatically stop when `.stop()` is called on the RecognizeStream.
87
88
88
-
Pipes results through a `{TimingStream}` by if `options.play=true`, set `options.realtime=false` to disable.
89
-
90
-
Pipes results through a `{FormatStream}` by default, set `options.format=false` to disable.
91
-
92
-
### Class `RecognizeStream()`
93
-
94
-
A [Node.js-style stream](https://nodejs.org/api/stream.html) of the final text, with some helpers and extra events built in.
95
-
96
-
RecognizeStream is generally not instantiated directly but rather returned as the result of calling one of the recognize* methods.
97
-
98
-
The RecognizeStream waits until after receiving data to open a connection.
99
-
If no `content-type` option is set, it will attempt to parse the first chunk of data to determine type.
100
-
101
-
See speech-to-text/recognize-stream.js for other options.
102
-
103
-
#### Methods
104
-
105
-
*`.promise()`: returns a promise that will resolve to the final text.
106
-
Note that you must either set `continuous: false` or call `.stop()` on the stream to make the promise resolve in a timely manner.
107
-
108
-
*`.stop()`: stops the stream. No more data will be sent, but the stream may still receive additional results with the transcription of already-sent audio.
109
-
Standard `close` event will fire once the underlying websocket is closed and `end` once all of the data is consumed.
110
-
111
-
#### Events
112
-
Follows standard [Node.js stream events](https://nodejs.org/api/stream.html), in particular:
113
-
114
-
*`data`: emits either final Strings or final/interim result objects depending on if the stream is in objectMode
115
-
*`end`: emitted once all data has been consumed.
89
+
Pipes results through a [TimingStream] by if `options.play=true`, set `options.realtime=false` to disable.
116
90
117
-
(Note: there are several custom events, but they are deprecated or intended for internal usage)
118
-
119
-
### Class `FormatStream()`
120
-
121
-
Pipe a `RecognizeStream` to a format stream, and the resulting text and `results` events will have basic formatting applied:
122
-
* Capitalize the first word of each sentence
123
-
* Add a period to the end
124
-
* Fix any "cruft" in the transcription
125
-
* A few other tweaks for asian languages and such.
126
-
127
-
Inherits `.promise()` from the `RecognizeStream`.
128
-
129
-
130
-
### Class `TimingStream()`
131
-
132
-
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.
133
-
134
-
Inherits `.promise()` from the `RecognizeStream`.
135
-
136
-
### Class `WritableElementStream()`
137
-
138
-
Accepts input from `RecognizeStream()` and friends, writes text to supplied `outputElement`.
91
+
Pipes results through a [FormatStream] by default, set `options.format=false` to disable.
139
92
140
93
141
94
## Changelog
@@ -201,3 +154,8 @@ Accepts input from `RecognizeStream()` and friends, writes text to supplied `out
201
154
* look for bug where single-word final results may omit word confidence (possibly due to FormatStream?)
202
155
* fix bug where TimingStream shows words slightly before they're spoken
203
156
* support jquery objects for element and targetElement
0 commit comments