Class: RecognizeStream

RecognizeStream

new RecognizeStream(options)

pipe()-able Node.js Readable/Writeable stream - accepts binary audio and emits text in it's data events. Also emits results events with interim results and other data.

Cannot be instantiated directly, instead reated by calling #createRecognizeStream()

Uses WebSockets under the hood. For audio with no recognizable speech, no data events are emitted.

Parameters:
Name Type Description
options
Properties
Name Type Attributes Default Description
model String <optional>
'en-US_BroadbandModel'

voice model to use. Microphone streaming only supports broadband models.

url String <optional>
'wss://stream.watsonplatform.net/speech-to-text/api'

base URL for service

content-type String <optional>
'audio/wav'

content type of audio; can be automatically determined from file header in most cases. only wav, flac, and ogg/opus are supported

interim_results Boolean <optional>
false

Send back non-final previews of each "sentence" as it is being processed. Defaults to true when in objectMode.

continuous Boolean <optional>
true

set to false to automatically stop the transcription after the first "sentence"

word_confidence Boolean <optional>
false

include confidence scores with results. Defaults to true when in objectMode.

timestamps Boolean <optional>
false

include timestamps with results. Defaults to true when in objectMode.

max_alternatives Number <optional>
1

maximum number of alternative transcriptions to include. Defaults to 3 when in objectMode.

inactivity_timeout Number <optional>
30

how many seconds of silence before automatically closing the stream (even if continuous is true). use -1 for infinity

readableObjectMode Boolean <optional>
false

emit result objects instead of string Buffers for the data events. Changes several other defaults.

X-WDC-PL-OPT-OUT Number <optional>
0

set to 1 to opt-out of allowing Watson to use this request to improve it's services

//todo: investigate other options at http://www.ibm.com/smarterplanet/us/en/ibmwatson/developercloud/apis/#!/speech-to-text/recognizeSessionless

Source:

Events

close

Parameters:
Name Type Description
reasonCode Number
description String
Source:

connection-close

Parameters:
Name Type Description
reasonCode Number
description String
Deprecated:
  • Yes
Source:

data

Finalized text

Parameters:
Name Type Description
transcript String
Source:

data

Object with interim or final results, possibly including confidence scores, alternatives, and word timing.

Parameters:
Name Type Description
data Object
Source:

error

Source:

results

Object with array of interim or final results, possibly including confidence scores, alternatives, and word timing. May have no results at all for empty audio files.

Parameters:
Name Type Description
results Object
Deprecated:
  • - use objectMode and listen for the 'data' event instead
Source:

results

Object with interim or final results, possibly including confidence scores, alternatives, and word timing.

Parameters:
Name Type Description
results Object
Deprecated:
  • - use objectMode and listen for the 'data' event instead
Source: