1

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.

Daisy_s
  • 109
  • 9

3 Answers3

0

Here is a link to a sample flow that uses Text to Speech on an HTML page. Take that as your starter, and add in Conversation.

https://github.com/watson-developer-cloud/node-red-labs/tree/master/basic_examples/text_to_speech

chughts
  • 4,210
  • 2
  • 14
  • 27
  • Hi, Thanks. I had already taken its reference. But in every sample the user puts a input text and that is converted to speech. While I would want the receivers reply from conversation service to be converted to speech using TTS. Is that possible? – Daisy_s Oct 15 '16 at 05:08
  • There are two basic html based sample flows that you can use. One for Conversation (https://github.com/watson-developer-cloud/node-red-labs/tree/master/basic_examples/conversation) which allows you enter text and receive a response back from the Conversation service. One for Text to Speech (https://github.com/watson-developer-cloud/node-red-labs/tree/master/basic_examples/text_to_speech) which allows you to hear the text you entered. It is not too difficult to use concepts from both to create the combined flow that you are looking for. – chughts Oct 15 '16 at 07:20
  • Ya, exactly its pretty simple. I sent the output from conversation node to TTS node at NodeRED. But i am unable to make the proper html template design of putting input for TTS from the receivers reply of conversation service. Ie link the conversation output to input of TTS at html. This is my first time using HTML for any front end so am struggling a bit. – Daisy_s Oct 15 '16 at 09:10
0

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.

  1. 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.

  2. you will need a node to retrieve the input, I used an inject node for the test.

  3. 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.

  4. connect that to a function node. I then have to move the response from the conversation from msg.payload.output.text[0] to msg.payload like so:

msg.payload = msg.payload.output.text[0]; return msg;

  1. 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.

  2. 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": []
}]
chaiboy
  • 165
  • 5
0

you need to provide more information about your problem.

anyway, one thing I've noticed is that text to speech generates a 44khz audio file. If you're running it locally in a RPI using some USB dongle, for example, it may not be able to play because it support by default 22Khz audio. So being able to play it locally also depends on the hardware and how the sound is configured in it.

Leo
  • 751
  • 4
  • 29