Re-create the Interpreter application

In this section, you will re-create the Interpreter application on GitHub, which is a Node-RED flow that translates audio recorded by a microphone into a variety of languages.

    1. Go to your Node-RED flow editor. Select and delete the wires.

    1. Drag and drop the speech to text node onto the canvas.

    1. Select the speech to text node and click the info tab.

    1. Scroll down and note that the input is expected to be an audio buffer on msg.payload.

    1. Scroll further down and note that the output will be placed on msg.transcription.

    1. Double-click the speech to text node to edit the configuration. Set the language to US English and select the Continuous check box. Then, click Done.

    1. Wire the microphone node to the speech to text node.

    1. Drag and drop a language translator node onto the canvas.

    1. Select the language translator node.

    1. Go to the info tab and note that the input is expected on msg.payload and the output is on msg.translation.

The speech to text node sends output to msg.transcription, but the language translator node expects input on msg.payload. This means that the nodes cannot be connected directly.

 

    1. Drag and drop a function node onto the canvas. Then, double-click the function node to edit it. Add the following name and code that allows the output from the speech to text node to be passed to the language translation node:
      Name:

      Prepare for Translation

      Function:
      msg.payload = msg.transcription;
      return msg;

    1. Click Done.
    2. Wire the speech to textfunction, and language translator nodes.

    1. Double-click the language translator node to configure it. Select your source and target language. For example, select English and Spanish. Then, click Done.

    1. Drag and drop the text to speech node onto the canvas. Then, select the node and look at the info tab.

    1. Scroll down and note that the input is expected on msg.payload and that the output will be placed on msg.speech.

      This means that the language translator node, which outputs the simple translation on msg.payload, can be connected directly to the text to speech node. However, the text to speech node cannot be connected directly to the play audio node.

    2. Double-click the text to speech node to configure it. Specify a language, voice, and format. Then, click Done.

    1. Drag and drop a function node onto the canvas. Then, double-click the function node to edit it. Under Function, set msg.payload = msg.speech so that it points to the audio from the text to speech service and it can be passed to the play audio node.

    1. Click Done.
    2. Wire the nodes together.

    1. Deploy your flow. You can now try recording audio with your application.
    2. To record yourself speaking, click the microphone tab, speak to your computer mic, and then click the tab again to stop the recording.

  1. Wait for your application to process your input and listen to the translated output.