Skip to content

Latest commit

 

History

History
 
 

readme.md

Watson Speech JavaScript SDK Examples

This folder has example Node.js and Python servers to generate auth tokens and several html files (in static/) with different examples of using the Speech SDK.

There are also a few audio files to test with in the static/ folder.

Prerequisite

Setup - Node.js

  1. cd into the examples/ directory and run npm install to grab dependencies (this automatically runs bower install)
  2. edit tts-token.js and stt-token.js to include your service credentials (or create a .env file)
  3. run npm start
  4. Open your browser to http://localhost:3000/ to see the examples.

Setup - Python

  1. cd into the examples/ directory and run pip install watson_developer_cloud flask (or easy_install...) to install python dependencies
  2. run bower install to install client-side dependencies
  3. edit server.py to include your service credentials (or create a .env file)
  4. run python server.py
  5. Open your browser to http://localhost:5000/ to see the examples.

Notes

  • The examples all use fetch (a modern promise-based replacement for XMLHttpRequest) to retrieve auth tokens. Most supported browsers include a native fetch implementation, but a pollyfill is included in the top-level module for older browsers.
  • The examples use a Node.js server to generate tokens. It doesn't have to be written in Node.js, but some server-side token generator is required. The SDK will not accept your service credentials directly, and you can not use them to generate a token client-side. SDKs are available for Node.js, Java, Python, and there is a REST API for use with other languages (or curl).
  • The Speech SDK may be used in browserify, Webpack, or as a standalone library. Most of the examples use the standalone version either installed via bower or symlinked to the root directory when developing locally.

More Examples