IBM Watson Speech Services for Web Browsers
Allows you to easily add voice recognition and synthesis to any web app with minimal code.
Built for Browsers
This library is primarily intended for use in web browsers. Check out watson-developer-cloud to use Watson services (speech and others) from Node.js.
However, a server-side component is required to generate auth tokens. The
examples/ folder includes example Node.js and Python servers, and SDKs are available for Node.js, Java, Python, and there is also a REST API.
Installation - standalone
Installation - bower
bower install --save watson-speech
Installation - npm with Browserify or Webpack
npm install --save watson-speech
This method enables a smaller bundle by only including the desired components, for example:
var recognizeMic = ;
Using with IAM
This SDK CAN be used in the browser with services that use IAM for authentication. This does require a server-side component - an endpoint used to retrieve the token. An example can be found here.
In a local environment you should set only the
SPEECH_TO_TEXT_IAM_APIKEY in your
.env file, see example file here.
Once that is set up, the token can be used in your SDK request with the parameter
access_token. See this example.
Using with Angular
polyfills.ts has following entries:
window as anyglobal = window;window as anyprocess = ;; // Included with Angular CLI.globalBuffer = globalBuffer || Buffer;
See CHANGELOG.md for a complete list of changes.
Use examples for development
The provided examples can be used to test developmental code in action:
npm run dev
This will build the local code, move the new bundle into the
examples/ directory, and start a new server at
localhost:3000 where the examples will be running.
Note: This requires valid service credentials.
The test suite is broken up into offline unit tests and integration tests that test against actual service instances.
npm testwill run the linter and the offline tests
npm run test-offlinewill run the offline tests
npm run test-integrationwill run the integration tests
To run the integration tests, a file with service credentials is required. This file must be called
stt-auth.json and must be located in
/test/resources/. There are tests for usage of both CF and RC service instances. For testing CF, the required keys in this configuration file are
password. For testing RC, a key of either
iam_apikey is required. Optionally, a service URL for an RC instance can be provided under the key
rc_service_url if the service is available under a URL other than
For an example, see