pipe()-able Node.js Duplex stream - accepts binary audio and emits text/objects in it's data
events.
pipe()-able Node.js Duplex stream - accepts binary audio and emits text/objects in it's data
events.
Uses WebSockets under the hood. For audio with no recognizable speech, no data
events are emitted.
By default, only finalized text is emitted in the data events, however when objectMode
/readableObjectMode
and interim_results
are enabled, both interim and final results objects are emitted.
WriteableElementStream uses this, for example, to live-update the DOM with word-by-word transcriptions.
Note that the WebSocket connection is not established until the first chunk of data is recieved. This allows for auto-detection of content type (for wav/flac/opus audio).
Uses WebSockets under the hood. For audio with no recognizable speech, no data
events are emitted.
By default, only finalized text is emitted in the data events, however when objectMode
/readableObjectMode
and interim_results
are enabled, both interim and final results objects are emitted.
WriteableElementStream uses this, for example, to live-update the DOM with word-by-word transcriptions.
Note that the WebSocket connection is not established until the first chunk of data is recieved. This allows for auto-detection of content type (for wav/flac/opus audio).
Name | Type | Attribute | Description |
---|---|---|---|
opts |
DuplexOptions | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
error |
Error | null | ||
callback |
function |
Name | Type | Attribute | Description |
---|---|---|---|
callback |
function |
Name | Type | Attribute | Description |
---|---|---|---|
size |
number |
Name | Type | Attribute | Description |
---|---|---|---|
chunk |
any | ||
encoding |
string | ||
callback |
function |
Name | Type | Attribute | Description |
---|---|---|---|
chunks |
Array<object> | ||
callback |
function |
Event emitter The defined events on documents including:
Name | Type | Attribute | Description |
---|---|---|---|
event |
"close" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"data" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"end" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"error" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"pause" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"readable" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"resume" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
error |
Error | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"close" |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"data" | ||
chunk |
any |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"end" |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"error" | ||
err |
Error |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"pause" |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"readable" |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"resume" |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | ||
args |
any[] | Rest |
Name | Type | Attribute | Description |
---|---|---|---|
cb |
function | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
chunk |
any | ||
cb |
function | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
chunk |
any | ||
encoding |
string | Optional | |
cb |
function | Optional |
Returns a Promise that resolves with Watson Transaction ID from the X-Transaction-ID header
Works in Node.js but not in browsers (the W3C WebSocket API does not expose headers)
Promise
Name | Type | Attribute | Description |
---|---|---|---|
type |
string | symbol |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"close" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"data" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"end" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"error" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"pause" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"readable" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"resume" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"close" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"data" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"end" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"error" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"pause" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"readable" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"resume" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
destination |
T | ||
options |
object | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"close" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"data" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"end" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"error" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"pause" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"readable" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"resume" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"close" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"data" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"end" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"error" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"pause" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"readable" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"resume" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
chunk |
any | ||
encoding |
string | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol |
Name | Type | Attribute | Description |
---|---|---|---|
size |
number | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"close" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"data" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"end" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"error" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"pause" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"readable" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
"resume" | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
event |
string | symbol | ||
listener |
function |
Name | Type | Attribute | Description |
---|---|---|---|
data |
any |
Name | Type | Attribute | Description |
---|---|---|---|
msg |
any |
Name | Type | Attribute | Description |
---|---|---|---|
encoding |
string |
Name | Type | Attribute | Description |
---|---|---|---|
encoding |
string |
Name | Type | Attribute | Description |
---|---|---|---|
n |
number |
Prevents any more audio from being sent over the WebSocket and gracefully closes the connection.
Additional data may still be emitted up until the end
event is triggered.
Name | Type | Attribute | Description |
---|---|---|---|
destination |
WritableStream | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
chunk |
any | ||
encoding |
BufferEncoding | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
oldStream |
ReadableStream |
Name | Type | Attribute | Description |
---|---|---|---|
chunk |
any | ||
encoding |
string | Optional | |
cb |
function | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
chunk |
any | ||
cb |
function | Optional |
A utility method for creating Readable Streams out of iterators.
Name | Type | Attribute | Description |
---|---|---|---|
iterable |
Iterable<any> | AsyncIterable<any> | ||
options |
ReadableOptions | Optional |
Name | Type | Attribute | Description |
---|---|---|---|
buffer |
Buffer |
Generated using TypeDoc
pipe()-able Node.js Readable/Writeable stream - accepts binary audio and emits text in its
data
events. Also emitsresults
events with interim results and other data.Cannot be instantiated directly, instead created by calling #recognizeUsingWebSocket()
Uses WebSockets under the hood. For audio with no recognizable speech, no
data
events are emitted.