0

I am using Node-Red to develop a application with both conversation and text to speech services. Goal is give text input and get both text and voice as output. I am able to create the application at node-red but facing trouble with how the template should be? Some one please help. P.S: the text to speech service is using input text from conversation output.

Daisy_s
  • 109
  • 9

1 Answers1

1

If I'm understanding your question correctly the following should help point you in the right direction.

The string output from the conversation is stored on the msg.payload.output.text object. Using a function node between the Conversation node and the Text to Speech node will let you set:

msg.payload = msg.payload.output.text

as required by Text to Speech

Additionally, the function node may have multiple outputs so you can pass the string to TTS and wherever else you fancy, just edit the following parameter of the function node:

outputs

An example function node that flows from the Conversation node to Speech to Text would have the following code:

if (msg.payload.output && msg.payload.output.text) {
    msg.payload = msg.payload.output.text.join(' ');
} else {
    msg.payload = 'No response';
}
return msg;

The following flows from the Node-RED labs should help you:

Text to Speech

Conversation

  • I am already using a function node inbetween conversation and Text-Speech node. – Daisy_s Oct 12 '16 at 07:25
  • The function node consist of : msg.mydata.messageout = msg.payload; msg.payload = {}; msg.payload.botresponse = msg.mydata; return msg; – Daisy_s Oct 12 '16 at 07:25
  • The Conversation node outputs it's message here: `msg.payload.output.text` Speech to Text expects it's input here: `msg.payload` So an example function node would do the following to flow from one to the other: ````if (msg.payload.output && msg.payload.output.text) { msg.payload = msg.payload.output.text.join(' '); } else { msg.payload = 'No response'; } return msg;```` – Chris Parsons Oct 12 '16 at 07:42
  • In current conversation template i am using this function: processOK(response) { console.log('003-001'); console.log(response); console.log(response.botresponse.messageout); console.log(response.botresponse.messageout.output.text); console.log(response.botresponse.messageout.context); chat('WATSON', response.botresponse.messageout.output.text); $('#id_contextdump').data('convContext', response.botresponse.messageout.context); } ie: conversation output message is in: [link] msg.payload.botresponse.messageout. – Daisy_s Oct 12 '16 at 08:59
  • Am I right in thinking that you're looking to follow [this](https://github.com/watson-developer-cloud/node-red-labs/tree/master/basic_examples/conversation) tutorial? The code you have sent here is intended for client side use, and won't run in Node-RED. If you look at the bottom of the example there is a walkthrough about how to set up the Node-RED flow/template correctly. Please ensure you're using a conversation flow similar to the example [here](https://github.com/watson-developer-cloud/node-red-labs/blob/master/basic_examples/conversation/conversation_lab.json). – Chris Parsons Oct 12 '16 at 11:45
  • This is my current node flow. But i am unable to get voice output from it. I guess i'm missing something at the template code. Can someone help me on what am I going wrong at? – Daisy_s Oct 13 '16 at 06:07
  • The template code doesn't affect audio output. If you would like to use the Conversation and Speech to Text API together, please follow this [tutorial](https://github.com/watson-developer-cloud/node-red-labs/tree/master/starter-kits/ok_watson) and let me know if you have any problems. – Chris Parsons Oct 14 '16 at 11:11
  • Hi Chris,Thanks. I did go through that tutorial, but they are using Microphone and Audio play node while i'm trying mine using HTTP post/get. Also i am attaching my current node-flow here. Can you please look into it and say what am i doing wrong. Appreciate a lot. – Daisy_s Oct 15 '16 at 05:12