Class: FormatStream

FormatStream

new FormatStream(opts)

Applies some basic formatting to transcriptions:

  • Capitalize the first word of each sentence
  • Add a period to the end
  • Fix any "cruft" in the transcription
  • etc.

    May be used as either a Stream, or a standalone helper.

Parameters:
Name Type Attributes Default Description
opts Object
Properties
Name Type Attributes Default Description
model String <optional>

some models / languages need special handling

hesitation String <optional>
''

what to put down for a "hesitation" event, also consider \u2026 (ellipsis: ...)

options.objectMode Boolean <optional>
false

emit result objects instead of string Buffers for the data events.

Source:

Methods

capitalize(text) → {string}

Capitalizes the first word of a sentence

Parameters:
Name Type Description
text String
Source:
Returns:
Type
string

clean(text, isFinal) → {String}

Formats one or more words, removing special symbols, junk, and spacing for some languages

Parameters:
Name Type Description
text String
isFinal Boolean
Source:
Returns:
Type
String

formatResult(data) → {Object}

Creates a new result with all transcriptions formatted

May be used outside of Node.js streams

Parameters:
Name Type Description
data Object
Source:
Returns:
Type
Object

formatString(str, isInterimopt) → {String}

Formats a single string result.

May be used outside of Node.js streams

Parameters:
Name Type Attributes Default Description
str String

text to format

isInterim bool <optional>
false

set to true to prevent adding a period to the end of the sentence

Source:
Returns:
Type
String

period(text) → {string}

Puts a period on the end of a sentence

Parameters:
Name Type Description
text String
Source:
Returns:
Type
string