Replacing Machine Translation with Conversation in Watson Speech-to-Speech demo

Hello,

I’m trying to create a watson chatbot that users can talk to, like siri. A user would say something to the app, the audio file would be parsed using Speech-to-text and Watson Conversation would determine an appropriate response, and the response would be translated back to speech.

I’ve found this Speech-to-Speech demo, created by IBM (https://github.com/leonrch/SpeechToSpeech). This is supposed to listen to users, turn the audio into text, translate that text, and turn the result back into speech. So, basically what I need but Conversation is swapped with Translation.

I’m wondering what the best way to switch conversation with translation. I essentially copied the “send message” example code in the API Reference for Conversation into the app, but I’m getting various errors depending on what I try. For example, if I put “var watson = require(‘watson-developer-cloud’);” in main.js, “watson-developer-cloud” isn’t recognized, even if I installed the package earlier.

If I put only the latter part of the example request into main.js, I get reference error: conversation is not defined.

conversation.message({
workspace_id: ’25dfa8a0-0263-471b-8980-317e68c30488′,
input: {‘text’: ‘Turn on the lights’},
context: context
}, function(err, response) {
if (err)
console.log(‘error:’, err);
else
console.log(JSON.stringify(response, null, 2));
});

Here is the request in full.

var watson = require(‘watson-developer-cloud’);

var conversation = watson.conversation({
username: ‘{username}’,
password: ‘{password}’,
version: ‘v1’,
version_date: ‘2017-05-26′
});

// Replace with the context obtained from the initial request
var context = {};

conversation.message({
workspace_id: ’25dfa8a0-0263-471b-8980-317e68c30488’,
input: {‘text’: ‘Turn on the lights’},
context: context
}, function(err, response) {
if (err)
console.log(‘error:’, err);
else
console.log(JSON.stringify(response, null, 2));
});

Been stuck for awhile, would appreciate any assistance.

Bobby

Related:

Leave a Reply