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/recognize-file(options) → {RecognizeStream}

Create and return a RecognizeStream from a File or Blob (e.g. from a file , a dtagdrop targe, 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

data Blob | File

the raw audio data as a Blob or File instance

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

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.

Source:
Returns:
Type
RecognizeStream

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

Create and return a RecognizeStream from the user's microphone If the options.file is set, it is used instead of the microphone

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

format Boolean <optional>
true

pipe the text through a {FormatStream} which performs light formatting

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.

Source:
Returns:
Type
RecognizeStream

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 (loading the top-level module automatically includes a pollyfill, but loading this sub-module directly doesn't.)

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

auth token

Source:
To Do:
  • define format in @returns 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.

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

autoPlay Boolean <optional>
true

automatically play the audio

element DOMAudioElement <optional>

Source:
See:
Returns:
Type
Audio

noTimestamps(result) → {Boolean}

Returns true if the result is missing it's timestamps

Parameters:
Name Type Description
result Object
Source:
Returns:
Type
Boolean

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

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

Parameters:
Name Type Description
file File | Blob
Source:
Returns:
Type
Promise.<FilePlayer>