I am trying to run the speech to text example recipe for my TJBot. The sample config.js file needs a username and password from IBM to authenticate the service. However, IBM seems to be migrating to a API key based authentication system, and does not provide any username/password pairs. How can I connect to the service?
It seems you are referencing this config.js as part of this TJBot recipe . Indeed are all the IBM Cloud services including the Watson services moving to an IAM-based authentication. Here is the Node.js API for Speech-to-Text on authentication which offers this way to authenticate in addition to username / password:
var speechToText = new SpeechToTextV1({
iam_apikey: '{iam_api_key}',
url: '{url}'
});
Based on the layout of config.js and that API, the TTS part in your config.js should look like this:
// Watson Speech to Text
// https://www.ibm.com/watson/services/speech-to-text/
exports.credentials.speech_to_text = {
iam_apikey: 'YOUR-API-KEY',
url: 'URL-FOR-SERVICE'
};
The STT recipe works now. Thanks to data_henrik for pointing out the required config.js edit. Besides editing the config file, I also edited node_modules/tjbot/lib/tjbot.js at line 381 and commented out the following block:
//assert(credentials.hasOwnProperty('username'), "credentials for the " + service + " service missing 'username'");
//assert(credentials.hasOwnProperty('password'), "credentials for the " + service + " service missing 'password'");
//var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
//this._stt = new SpeechToTextV1({
// username: credentials['username'],
// password: credentials['password'
// url: 'https://stream.watsonplatform.net/speech-to-text/api/',
// version: 'v1'
// });
// break;`
and replaced it with this:
var SpeechToTextV1 = require('watson-developer-cloud/speech-to-text/v1');
this._stt = new SpeechToTextV1({
iam_apikey: credentials['iam_apikey'],
url: 'https://gateway-syd.watsonplatform.net/speech-to-text/api',
version: 'v1'
});
break;`
@data_henrik you solution may work. But a better solution is to edit the config.js directly as follows (note the keywork is apikey, not iam_apikey):
// Watson Speech to Text
// https://www.ibm.com/watson/services/speech-to-text/
exports.credentials.speech_to_text = {
apikey: 'YOUR-API-KEY',
url: 'URL-FOR-SERVICE'
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.