Skip to content

IBM Watson Speech toText

Thomas David Kehoe edited this page Aug 8, 2017 · 3 revisions

Make a project in IBM Bluemix. You'll be provided a username and password. Use the username and password to get a token. The token must specify "/speech-to-text/".

curl -X GET --user af02b2e3-064c-46f0-922c-56ae6a1e7854:LUHc0mlK002x \ --output token \ "https://stream.watsonplatform.net/authorization/api/v1/token?url=https://stream.watsonplatform.net/speech-to-text/api"

Tokens expire in one hour.

The session steps are:

  1. Open a session.
  2. Starting transcribing.
  3. Stop transcribing.
  4. Close session.

You also need to log messages:

function onMessage(evt) { console.log(evt.data); }

websocket.onmessage = function(evt) { onMessage(evt) };

Opening a Session

function onOpen(evt) { var message = { 'action': 'start', 'content-type': 'audio/l16;rate=22050' }; websocket.send(JSON.stringify(message)); };

websocket.onopen = function(evt) { onOpen(evt) };

You'll get back the message:

{ "state": "listening" }

Clone this wiki locally