【问题标题】:How to include bluemix text to speech services using Node如何使用 Node 将 bluemix 文本包含到语音服务中
【发布时间】:2016-09-05 14:12:12
【问题描述】:

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

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

在我的 index.js 中。

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

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

【问题讨论】:

  • 他们的文档中有一个很好的例子,除了“未定义”之外,您还有其他可以帮助我们帮助您的错误吗?首先,你应该使用var TextToSpeechV1 = require('watson-developer-cloud/text-to-speech/v1');`npmjs.com/package/watson-developer-cloud#text-to-speech
  • 它说 require 没有定义,我读到我不能在 jquery 或客户端使用 require。我也研究了browserify

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


【解决方案1】:

在你的 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');  } });
}

【讨论】:

  • 谢谢 - 原来我试图在我的客户端代码中做一个 require(watson)
【解决方案2】:

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

【讨论】:

  • 是的,我将 npm watson-developer-cloud 添加到我的管道中,但它似乎没有解决问题
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多