4. Add speech input

In this section, you add speech as an input channel to your application.

    1. Drag an input microphone node onto the canvas.
    2. Drag a Watson speech to text node onto the canvas.
    3. Drag a function node onto the canvas.
    4. Add a script in the function node to move speech transcription to the payload:msg.payload = msg.transcription;
      return msg;

    5. Configure the speech to text
    6. Wire the nodes together.
    7. Optional: Add input and output link nodes to make your flow easier to work with.
    8. Test your phrase parser with spoken text.

In this example, the text is being interpreted with an incorrect class, so extra text was added with the misspelling to the training data for the Natural Language Classifier.

    1. On Bluemix, open the Natural Language Classifier tooling and select your classifier.
    2. Find the section that allows you to test and improve the performance of your classifier. Enter the text that was incorrectly classified and click Classify.

The classification should return incorrectly. This is expected because you are retraining the classifier to account for this misclassification.

    1. Flag the classification as incorrect.
    2. Try other text. When you are done, click Add to training data.
    3. Remove the suggested classification by clicking the X.
    4. Assign a new class.

In this case, the class should be turn-off.

    1. Assign the class turn-off to the text.
    2. Click Create classifier.
    3. Name the classifier something like iot-action2 to distinguish it from your existing classifier.

You should now be able to see both classifiers in Node-RED.

  1. Make a note of the new classifier id (for iot-action2) and reconfigure the natural language classifier node to use it.


You now have a way to parse phrases to understand the action being requested and to act on the request.