如何使用 Node 将 bluemix 文本包含到语音服务中

How to include bluemix text to speech services using Node

我有一个使用对话服务的 bluemix 应用程序,我正在尝试使用以下方法将文本转语音服务包括在内:

var watson = require('watson-developer-cloud'); 

在我的 index.js.

我收到一个未定义的错误。

我已经尝试在构建管道上添加 npm install watson-developer-cloud 但它不起作用。我也试过 browserify。

如果不查看更多的构建管道,很难看出您的 npm install 命令是否 运行 正确。我建议您将 watson-developer-cloud 添加到 package.json

的依赖项列表中

在您的 app.js 中声明

var watson = require('watson-developer-cloud'); app.get('/test', function(req, res) { //call all req function here });

在你的Index.js添加

$('#text_to speech').click(function(e){

$.ajax({ type: 'GET', data: { text: "text to speech" }, url: '/test' , success: function(response) { console.log('success');  } });
}