I am trying to develop a web application using Watson Conversation service and Watson TTS service. The conversation output is sent to the TTS service for conversion. I am doing this in NodeRED and also i have put a function node between conversation node and TTS node which assigns the payload. After deployment I am only getting the conversational dialog chatbot but not the speech as I am suppose to. Please help me figure out what am I missing?
*PS: I am using HTTP post and HTTP get for this.
I built a flow that works and you will need to install a node that can play audio. The text to speech node does not actually play any sound. It creates an audio file.
Go to the hamburger in the upper right of the node red editor. Look for Palette Manager. look for node-red-contrib-play-audio
and install it. I assume you have node-red-bluemix-nodes
already.
you will need a node to retrieve the input, I used an inject node for the test.
connect it to your conversation node. Double click it and put the Workspace ID. (it is on the workspace under the three dots in the upper right of each one. Copy that long string into your node. I used the default car tutorial.
msg.payload = msg.payload.output.text[0];
return msg;
connect that to a text to speech node. Fill in any credentials, pick a voice and click the output to msg.payload. If you forget to do this then the audio node will actually read the text instead of using the text to speech node's voice. The audio node's voice is not great.
connect the play audio node.
That is it. You should have a working voice.
A good way to see what is going on is to use a debug node. This lets you see where content is flowing and drop in functions to redirect the output appropriately for each node.
Copy the code below and go into the hamburger and do an import from clipboard to a new flow. You will need to fill in appropriate passwords and workspace ids but this shows how it is working.
[{
"id": "b7b6d9fc.1997f8",
"type": "tab",
"label": "Flow 2"
}, {
"id": "d0ed4492.045c18",
"type": "inject",
"z": "b7b6d9fc.1997f8",
"name": "",
"topic": "",
"payload": "play the radio",
"payloadType": "str",
"repeat": "",
"crontab": "",
"once": false,
"x": 159.5,
"y": 122,
"wires": [
["dc33249.3227bd8"]
]
}, {
"id": "dc33249.3227bd8",
"type": "watson-conversation-v1",
"z": "b7b6d9fc.1997f8",
"name": "",
"workspaceid": "",
"multiuser": false,
"context": true,
"default-endpoint": true,
"service-endpoint": "https://gateway.watsonplatform.net/conversation/api",
"x": 383.5,
"y": 121,
"wires": [
["d3c07b87.22f9c8"]
]
}, {
"id": "711b8067.a1c7",
"type": "debug",
"z": "b7b6d9fc.1997f8",
"name": "",
"active": true,
"console": "false",
"complete": "true",
"x": 751.5,
"y": 200,
"wires": []
}, {
"id": "9826b891.eb02b8",
"type": "watson-text-to-speech",
"z": "b7b6d9fc.1997f8",
"name": "",
"lang": "en-US",
"langhidden": "en-US",
"langcustom": "NoCustomisationSetting",
"langcustomhidden": "",
"voice": "en-US_MichaelVoice",
"voicehidden": "",
"format": "audio/wav",
"password": "",
"payload-response": true,
"default-endpoint": true,
"service-endpoint": "https://stream.watsonplatform.net/text-to-speech/api",
"x": 757.5,
"y": 64,
"wires": [
["ccf6f5a7.700508"]
]
}, {
"id": "d3c07b87.22f9c8",
"type": "function",
"z": "b7b6d9fc.1997f8",
"name": "",
"func": "msg.payload = msg.payload.output.text[0];\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 561.5,
"y": 120,
"wires": [
["9826b891.eb02b8", "711b8067.a1c7"]
]
}, {
"id": "ccf6f5a7.700508",
"type": "play audio",
"z": "b7b6d9fc.1997f8",
"name": "",
"voice": "0",
"x": 963.5,
"y": 64,
"wires": []
}]