Execute a script when speech is created.
How to add the Speech Script robot skill
- Load the most recent release of ARC (Get ARC).
- Press the Project tab from the top menu bar in ARC.
- Press Add Robot Skill from the button ribbon bar in ARC.
- Choose the Audio category tab.
- Press the Speech Script icon to add the robot skill to your project.
Don't have a robot yet?
Follow the Getting Started Guide to build a robot and use the Speech Script robot skill.
How to use the Speech Script robot skill
Execute a script when speech is created. With this skill, you can create a function that will move servos or LEDs based on spoken speech. The code can be a loop because the script will be canceled when the speech has completed.Variable
The variable containing the speech is set as $SpeechTxt
*Note: to avoid a recursive never-ending loop, do not speak text in the script of this skill. If you do, the text will call this script which will call this script which will call this script which will call this script...
Example Script (Talk Servo)
This example script will move a servo on port D0 as a jaw. Position 10 is the closed mouth, and 100 is an open mouth. There is a delay set for vowels, constants, and end of the sentence. These would be tweaked based on the speed of speaking.
Code:
var words = getVar("$SpeechTxt").split(" ");
for (var wi = 0; wi < words.length; wi++)
for (var i = 0; i < words[wi].length; i++) {
var c = words[wi][i];
switch (c) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
case 'y':
// open mouth vowels
Servo.setPosition(d0, 100);
sleep(100);
break;
case '.':
case ',':
case '?':
case '!':
// close mouth for end of sentence
Servo.setPosition(d0, 10);
sleep(500);
break;
default:
// close mouth for constants
Servo.setPosition(d0, 10);
sleep(100);
break;
}
}
Upgrade to ARC Pro
Get access to the latest features and updates with ARC Pro edition. You'll have everything that's needed to unleash your robot's potential!

robo rad
PRO
Canada
#1

robo rad
PRO
Canada
#2