Search code examples
ibm-cloudtext-to-speechibm-watson

How to include bluemix text to speech services using Node


I have a bluemix app using dialog service and I am trying to include the text to speech service using:

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

in my index.js.

I get an undefined error.

I already tried adding npm install watson-developer-cloud on the build pipeline but it does not work. I also tried browserify.


Solution

  • In your app.js declare

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

    In your Index.js Add

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