Class: TimingStream

TimingStream

new TimingStream(opts)

Slows results down to no faster than real time.

Useful when running recognizeBlob because the text can otherwise appear before the words are spoken

Parameters:
Name Type Description
opts Object
Properties
Name Type Attributes Default Description
emitAtt * <optional>
TimingStream.START

set to TimingStream.END to only emit text that has been completely spoken.

delay Number <optional>
0

Additional delay (in seconds) to apply before emitting words, useful for precise syncing to audio tracks. May be negative

Source:

Methods

getCurrentResult(results, cutoff) → {*}

Returns one of:

  • undefined if the next result is completely later than the current cutoff
  • a cropped clone of the next result if it's later than the current cutoff && in objectMode
  • the original next result object (removing it from the array) if it's completely earlier than the current cutoff (or we're in string mode with emitAt set to start)
Parameters:
Name Type Description
results
cutoff
Source:
Returns:
Type
*

handleResult(result)

Creates a new result with all transcriptions formatted

Parameters:
Name Type Description
result
Source:

scheduleNextTick(cutoff)

Schedules next tick if possible. Requires previous stream to emit recognize objects (objectMode or readableObjectMode)

triggers the 'close' and 'end' events if the buffer is empty and no further results are expected

Parameters:
Name Type Description
cutoff
Source:

tick()

Tick emits any buffered words that have a timestamp before the current time, then calls scheduleNextTick()

Source: