【问题标题】:IBM Watson Speech-to-Text authentication credentialsIBM Watson Speech-to-Text 身份验证凭证
【发布时间】:2018-12-31 07:03:17
【问题描述】:

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

【问题讨论】:

    标签: ibm-cloud credentials ibm-watson speech-to-text


    【解决方案1】:

    您似乎将这个config.js 引用为这个TJBot recipe 的一部分。事实上,包括 Watson 服务在内的所有 IBM Cloud 服务都转向基于 IAM 的身份验证。这是Node.js API for Speech-to-Text on authentication,除了用户名/密码之外,它还提供了这种身份验证方式:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        【解决方案3】:

        @data_henrik 你的解决方案可能有效。但更好的解决方案是直接编辑config.js如下(注意keywork是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'
        };
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2017-07-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-01-01
          • 1970-01-01
          相关资源
          最近更新 更多