AI Robot Chat
This tutorial shows how to connect speech recognition to an AI chatbot so your robot can hear what you say, send that text to a PandoraBot, and speak the response. You can follow these steps in an existing project or start from a blank project.
Requirements
- Synthiam ARC installed
- Working microphone
- Sound card or an EZ-B with audio support (see EZB hardware overview to check compatibility)
- An active internet connection
Robot Skills Used
The tutorial uses these robot skills. Click any item for the skill manual:
Programming Concepts Used
This tutorial demonstrates these ARC programming concepts and APIs:
Steps
-
Add the Bing Speech Recognition skill
In ARC, add the Bing Speech Recognition robot skill from the top menu: Project > Add Robot Skill > Speech Recognition > Bing Speech Recognition.
Selecting the Bing Speech Recognition skill from the Add Robot Skill menu. -
Add the PandoraBot skill
From the top menu, add the PandoraBot skill: Project > Add Robot Skill > Artificial Intelligence > PandoraBots.
Selecting the PandoraBots skill from the Add Robot Skill menu. -
Open the Bing Speech Recognition config
Open the Bing Speech Recognition skill and press the Config button in its menu bar to open its configuration window.
Click the Config button to access the Bing Speech Recognition settings. -
Edit the "All Recognized Scripts"
Click the All Recognized Scripts button. This script runs for every phrase the speech recognition translates. Note the variable shown — you will reference it shortly.
The All Recognized Scripts area handles every recognized speech phrase. -
Switch to the JavaScript editor
When the script editor opens, switch to the JavaScript tab to insert code that will forward recognized text to PandoraBot.
Select the JavaScript tab to write the forwarding script. -
Insert the PandoraBot SetPhrase command
Right-click in the editor, choose PandoraBot, then select the SetPhrase option. This inserts the ControlCommand call used to send text to the chatbot.
Use the context menu to insert the PandoraBot SetPhrase command into your script. -
Replace the placeholder phrase
With the inserted code visible, highlight the placeholder text ("[phrase]"). You will replace it with the speech variable that contains the translated text.
Highlight the placeholder text to prepare for the variable insertion. -
Insert the $BingSpeech variable
Open the Global Variables tab, find the
$BingSpeechvariable, and click it. This inserts the variable at the cursor location, replacing the placeholder. The variable contains the text recognized by the Bing skill.
Insert the $BingSpeech global variable so the recognized text is forwarded to PandoraBot. -
Resulting code
The final code instructs ARC to send the contents of
$BingSpeechto the PandoraBot skill using ControlCommand. It should look like this:ControlCommand("PandoraBot", "SetPhrase", getVar("$BingSpeech"));This line uses ControlCommand() to call the PandoraBot skill's SetPhrase action with the recognized speech text.
-
Save the script
Press SAVE in the script editor to store your changes.
Save your JavaScript changes in the editor. -
Enable voice activity detection (optional but recommended)
Check Auto Record using VAD to let ARC automatically detect human speech and begin recording when you speak. Hover the blue question mark for details on how VAD works.
Enable Auto Record using VAD to automatically start recording when speech is detected. -
Save the Bing Speech configuration
Press SAVE in the Bing Speech Recognition configuration to apply all changes to the robot skill.
Save the configuration to activate the script and settings. -
Optional: Use the EZ-B speaker for PandoraBot TTS
If you have an EZ-B with supported audio (for example EZ-Robot EZ-B v4 or IoTiny), you can configure PandoraBot to play speech through the EZ-B speaker. Open the PandoraBot config (three dots in the title bar), check Use EZ-B v4 Speaker, and press save.
Enable the EZ-B speaker option to have PandoraBot responses play through the EZ-B device. -
You're done — test the conversation
Speak to the robot. The Bing Speech Recognition skill will translate your speech to text, the script will forward that text to PandoraBot, and PandoraBot will respond. Verify recording and audio output are working on your system.
When configured correctly, your robot can converse by forwarding recognized speech to PandoraBot and playing the response.