[英]IBM Watson Speech-to-Text speech-javascript-sdk "HTTP Authentication failed; no valid credentials available"
[英]IBM Watson Speech-to-Text authentication credentials
我正在嘗試為我的TJBot編寫文本示例配方的演講。 樣本config.js文件需要IBM的用戶名和密碼來驗證服務。 但是,IBM似乎正在遷移到基於API密鑰的身份驗證系統,並且不提供任何用戶名/密碼對。 如何連接到服務?
看來您是在此TJBot配方中引用此config.js的 。 實際上,包括Watson服務在內的所有IBM Cloud服務都已轉向基於IAM的身份驗證。 這是用於身份驗證上語音到文本的Node.js API ,除了用戶名/密碼外,還提供了這種身份驗證方式:
var speechToText = new SpeechToTextV1({
iam_apikey: '{iam_api_key}',
url: '{url}'
});
基於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'
};
STT配方現在可以使用。 感謝data_henrik指出所需的config.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您的解決方案可能會起作用。 但是更好的解決方案是直接按如下方式編輯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.