2015-11-30 74 views
1

我正在嘗試用於bluemix的語音文本的示例node.js程序。我在api憑證的用戶名和密碼中添加了內容,但是當我運行程序時node.js,我被給了一個Error: Server responded with a non-101 status:403。有誰知道什麼可能導致這個錯誤?node.js用於bluemix的語音文本示例程序給出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

+0

請出示的代碼,你[R什麼想 –

+0

很難沒有我使用的是內測帳號雖然任何代碼示例 – ianaya89

回答

2

服務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' 
}); 
+0

說,這是由憑證管理器提供的服務URL。無論如何,我已經嘗試了兩種方法,問題仍然存在。感謝您的幫助,雖然 – zen

+0

測試版服務不再可用。嘗試創建一個新的服務實例並從那裏開始 –