[英]IBM Watson Speech-to-Text authentication credentials
I am trying to run the speech to text example recipe for my TJBot. 我正在尝试为我的TJBot编写文本示例配方的演讲。 The sample config.js file needs a username and password from IBM to authenticate the service. 样本config.js文件需要IBM的用户名和密码来验证服务。 However, IBM seems to be migrating to a API key based authentication system, and does not provide any username/password pairs. 但是,IBM似乎正在迁移到基于API密钥的身份验证系统,并且不提供任何用户名/密码对。 How can I connect to the service? 如何连接到服务?
It seems you are referencing this config.js as part of this TJBot recipe . 看来您是在此TJBot配方中引用此config.js的 。 Indeed are all the IBM Cloud services including the Watson services moving to an IAM-based authentication. 实际上,包括Watson服务在内的所有IBM Cloud服务都已转向基于IAM的身份验证。 Here is the Node.js API for Speech-to-Text on authentication which offers this way to authenticate in addition to username / password: 这是用于身份验证上语音到文本的Node.js API ,除了用户名/密码外,还提供了这种身份验证方式:
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: 基于config.js和该API的布局,config.js中的TTS部分应如下所示:
// 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. STT配方现在可以使用。 Thanks to data_henrik for pointing out the required config.js edit. 感谢data_henrik指出所需的config.js编辑。 Besides editing the config file, I also edited node_modules/tjbot/lib/tjbot.js at line 381 and commented out the following block: 除了编辑配置文件外,我还在第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;`
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. @data_henrik您的解决方案可能会起作用。 But a better solution is to edit the config.js directly as follows (note the keywork is apikey, not iam_apikey): 但是更好的解决方案是直接按如下方式编辑config.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'
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.