IBM Watson 语音转文本身份验证凭据



我正在尝试为我的 TJBot 运行语音到文本示例配方。样本 config.js 文件需要 IBM 提供的用户名和密码来认证服务。但是,IBM 似乎正在迁移到基于 API 密钥的身份验证系统,并且不提供任何用户名/密码对。如何连接到服务?

您似乎正在引用此配置.js作为此 TJBot 配方的一部分。事实上,包括Watson服务在内的所有IBM云服务都转向基于IAM的身份验证。以下是用于身份验证语音转文本的 Node.js API,除了用户名/密码外,它还提供这种身份验证方式:

var speechToText = new SpeechToTextV1({
iam_apikey: '{iam_api_key}',
url: '{url}'
});

根据配置的布局.js和该 API,配置中的 TTS 部分.js应如下所示:

// 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'
};

STT 配方现在可以工作了。感谢data_henrik指出所需的配置.js编辑。除了编辑配置文件,我还在第 381 行编辑了node_modules/tjbot/lib/tjbot.js并注释掉了以下块:

//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;`

并用这个替换它:

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您的解决方案可能有效。但更好的解决方案是直接编辑配置.js如下所示(请注意,键是 apikey,而不是 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'
};

最新更新