用于bluemix的语音文本的node.js示例程序给出403错误

我正在尝试使用node.js程序来将bluemix的语音转换为文本。我在api凭证的用户名和密码中添加了一些内容,但是当我在node.js上运行该程序时,出现了一个Error: Server responded with a non-101 status:403 。 有谁知道什么可能导致这个错误?

这是示例代码

 'use strict'; var watson = require('watson-developer-cloud'); var fs = require('fs'); var speech_to_text = watson.speech_to_text({ username: '{username}', password: '{password}', version: 'v1', url: 'https://stream.watsonplatform.net/speech-to-text-beta/api' }); var params = { content_type: 'audio/wav', }; // create the stream var recognizeStream = speech_to_text.createRecognizeStream(params); // // pipe in some audio fs.createReadStream(__dirname + '/resources/speech.wav').pipe(recognizeStream); // // and pipe out the transcription recognizeStream.pipe(fs.createWriteStream('transcription.txt')); // listen for 'data' events for just the final text // listen for 'results' events to get the raw JSON with interim results, timings, etc. recognizeStream.setEncoding('utf8'); // to get strings instead of Buffers from `data` events ['data', 'results', 'error', 'connection-close'].forEach(function(eventName) { recognizeStream.on(eventName, console.log.bind(console, eventName + ' event: ')); }); 

谢谢

*道歉没有附上示例代码ealier

服务url是错误的。

代替:

 https://stream.watsonplatform.net/speech-to-text-beta/api 

使用:

 https://stream.watsonplatform.net/speech-to-text/api 

或者离开它。 例如:

 var speech_to_text = watson.speech_to_text({ username: '{username}', password: '{password}', version: 'v1' });