Global

Methods

getContentTypeFromFile(file) → {Promise}

Reads the first few bytes of a binary file and resolves to the content-type if recognized & supported

Parameters:
Name Type Description
file File | Blob
Source:
Returns:
Type
Promise

module:watson-speech/speech-to-text/get-models(options) → {Promise.<T>}

Returns a promise that resolves to an array of objects representing the available voice models. Example:

 [{
    "url": "https://stream.watsonplatform.net/speech-to-text/api/v1/models/en-UK_BroadbandModel",
    "rate": 16000,
    "name": "en-UK_BroadbandModel",
    "language": "en-UK",
    "description": "UK English broadband model."
 },
 //...
 ]

Requires fetch, pollyfill available at https://github.com/github/fetch

Parameters:
Name Type Description
options Object
Properties
Name Type Description
token String

auth token

Source:
To Do:
  • define format in @return statement
Returns:
Type
Promise.<T>

module:watson-speech/speech-to-text/recognize-file(options) → {RecognizeStream|SpeakerStream|FormatStream|ResultStream|TimingStream}

Create and return a RecognizeStream from a File or Blob (e.g. from a file , a dragdrop target, or an ajax request)

Parameters:
Name Type Description
options Object

Also passed to {MediaElementAudioStream} and to {RecognizeStream}

Properties
Name Type Attributes Default Description
token String

Auth Token - see https://github.com/watson-developer-cloud/node-sdk#authorization

file Blob | FileString

String url or the raw audio data as a Blob or File instance to be transcribed (and optionally played). Playback may not with with Blob or File on mobile Safari.

play Boolean <optional>
false

If a file is set, play it locally as it's being uploaded

format Boolena <optional>
true

pipe the text through a {FormatStream} which performs light formatting. Also controls smart_formatting option unless explicitly set.

realtime Boolena <optional>
options.play

pipe the text through a {TimingStream} which slows the output down to real-time to match the audio playback.

outputElement String | DOMElement <optional>

pipe the text to a WriteableElementStream targeting the specified element. Also defaults objectMode to true to enable interim results.

extractResults Boolean <optional>
false

pipe results through a ResultExtractor stream to simplify the objects. (Default behavior before v0.22) Automatically enables objectMode.

resultsBySpeaker Boolean <optional>
false

pipe results through a SpeakerStream. Causes each data event to include multiple results, each with a speaker field. Automatically enables objectMode and speaker_labels. Adds some delay to processing.

Source:
Returns:
Type
RecognizeStream | SpeakerStream | FormatStream | ResultStream | TimingStream

module:watson-speech/speech-to-text/recognize-microphone(options) → {RecognizeStream|SpeakerStream|FormatStream|ResultStream}

Create and return a RecognizeStream sourcing audio from the user's microphone

Parameters:
Name Type Description
options Object

Also passed to {RecognizeStream}, and {FormatStream} when applicable

Properties
Name Type Attributes Default Description
token String

Auth Token - see https://github.com/watson-developer-cloud/node-sdk#authorization

format Boolean <optional>
true

pipe the text through a FormatStream which performs light formatting. Also controls smart_formatting option unless explicitly set.

keepMicrophone Boolean <optional>
false

keeps an internal reference to the microphone stream to reuse in subsequent calls (prevents multiple permissions dialogs in firefox)

outputElement String | DOMElement <optional>

pipe the text to a WriteableElementStream targeting the specified element. Also defaults objectMode to true to enable interim results.

extractResults Boolean <optional>
false

pipe results through a ResultStream stream to simplify the objects. (Default behavior before v0.22) Requires objectMode.

resultsBySpeaker Boolean <optional>
false

Pipe results through a SpeakerStream. Forces speaker_labels and objectMode to be true.

mediaStream MediaStream <optional>

Optionally pass in an existing MediaStream

Source:
Returns:
Type
RecognizeStream | SpeakerStream | FormatStream | ResultStream

module:watson-speech/text-to-speech/get-voices(options) → {Promise.<T>}

Returns a promise that resolves to an array of objects representing the available voices. Example:

 [{
    "name": "en-US_MichaelVoice",
    "language": "en-US",
    "customizable": true,
    "gender": "male",
    "url": "https://stream.watsonplatform.net/text-to-speech/api/v1/voices/en-US_MichaelVoice",
    "description": "Michael: American English male voice."
 },
 //...
 ]

Requires fetch, pollyfill available at https://github.com/github/fetch

Parameters:
Name Type Description
options Object
Properties
Name Type Description
token String

auth token

Source:
To Do:
  • define format in @return statement
Returns:
Type
Promise.<T>

module:watson-speech/text-to-speech/synthesize(options) → {Audio}

Synthesize and play the supplied text over the computers speakers.

Creates and returns a HTML5 <audio> element

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
token String

auth token

text String

text to speak

voice String <optional>
en-US_MichaelVoice

what voice to use - call getVoices() for a complete list.

accept String <optional>

specify desired audio format. Leave unset to allow (most) browsers to automatically negotiate an ideal format.

X-Watson-Learning-Opt-Out Number <optional>
0

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

autoPlay Boolean <optional>
true

automatically play the audio

element DOMAudioElement <optional>

Source:
See:
Returns:
Type
Audio

playFile(file) → {Promise.<FilePlayer>}

Determines the file's content-type and then resolves to a FilePlayer instance

Parameters:
Name Type Description
file File | Blob | String

binary data or URL of audio file (binary data playback may not work on mobile Safari)

Source:
Returns:
Type
Promise.<FilePlayer>