NodeJS port of https://github.com/Speechpad/APILite wrapping the Speechpad API functionality.
$ npm install speechpad
This package depends on the config package for configuration.
To create a basic configuration do the following
$ mkdir config
$ vi config/default.json
{
"rest_uri": "http://dev.speechpad.com/services",
"access_key": "sandbox_key",
"secret_key": "sandbox_secret"
}
Edit config overrides for production deployment:
$ vi config/production.json
{
"rest_uri": "https://www.speechpad.com/services",
"access_key": "production_key",
"secret_key": "production_secret"
}
const APILite = require('speechpad');
// no further configuration is needed
// see examples/test.js
const params = {
'service_name': 'account',
'service_version': '1.0.0',
'format': 'json',
'method': 'get',
'operation': 'test',
'value': '123'
};
APILite.call(params).then((res) => {
console.log(res.data);
});
There are a handful of example scripts inside the package directory (node_modules/speechpad/examples
) provided to illustrate some basic usage of the Speechpad API.
All examples below assume:
- you have valid keys in config/default.json (for sandbox) or config/production.json (for production)
- are running the scripts on a web server
- are making requests to the examples provided
NOTE: We recommend running the examples against the sandbox endpoint only. Any usage against the production endpoint may result in your account being invoiced or charged.
$ node examples/test
$ node examples/add_media_url "https://www.speechpad.com/is_a.mp3"
(Replace https://www.speechpad.com/is_a.mp3 with a public URL to your own media.)
$ node examples/transcription_status "12345,12346"
(Replace "12345,12346" with the ID (or comma-separated list of IDs) of the media you are checking.)
$ node examples/get_transcription "12345"
(Replace 12345 with single media ID.)