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 after the speech is completed.
Variable The variable containing the speech that is currently speaking 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...
Main Screen
Stop Script Button A button on the main screen can be pushed to stop the currently running script. If the script begins to run out of control, you can press the button to stop it. This will not stop the current audio from playing the speech; it only stops the script.
Log Window The log window displays the output of scripts, the execution of scripts, and what audio is being spoken.
Configuration Window
There are two scripts that can be configured in the configuration window of this robot skill. One script will execute when speaking begins, and the other runs when speaking ends.Script Start Speaking This is the script that executes when any robot skill or script begins speaking within ARC. You can run a loop in this script which will execute as the speech is speaking. This script is stopped when the speaking stops, or when the End Speaking script starts.
Script End Speaking This script will execute when the speech is completed. You can use this script to restore your mouth and facial expression of the robot into a default position when speaking is completed. This script stops the Start Speaking script when it is executed.
Examples
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 the end of the sentence. These would be tweaked based on the speed of speaking.
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;
}
}
The changes aren't helping, they're not even functioning. The best option is the one described in the description, more accurate. It partially helps to adjust the rhythm using speech speed, slowing down or speeding up speech. But that's not the right approach. It's only for testing purposes, to identify issues and possibilities. For actual operation, it's necessary to do it the way light music was done before, where lights blinked to the music. There's sound-there's movement; no sound-no movement. In our case, it's with servos. In my case, the sound ended, but the servos continue to work. I tested it with equipment: EZ-B v4, EZ-B IoTiny.
I don't see how the code above doesn't work. Athena had added syllables for the German language to make the mouth move differently. The rest of the code is fine. I highly recommend you revisit that example and make modifications as needed. Athena can help with your changes in this thread regarding Speech Script.
This robot skill was updated to version 4, which now includes a script executed when speaking is completed. When speaking is completed, you can use this script to move a robot into a default position.
The only issue with this setup lies in the synchronization between the voice and the servo drive. Everything else is functioning properly. That's why I chose this particular skill. I mentioned its advantages and disadvantages right away.
@Athena, fix spelling errors in your script.
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].toLowerCase();
I apologize for any confusion caused by spelling errors in the script. Here is the corrected version of the example script for the German language, taking into account the phonetic characteristics and timing adjustments:
Please make sure to test and adjust the
sleep
values to match the speech rate and servo speed. If you need further assistance with the script or have specific requirements for the German language, feel free to ask, and I'll be happy to help you refine the script.I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
@Athena, $SpeechTxt should be replaced with "$SpeechTxt"
Who's helping who? Is artificial intelligence helping me or am I helping artificial intelligence?
I apologize for the oversight. The variable
$SpeechTxt
should indeed be used to access the current speech text. Here is the corrected script with the proper variable name:Please ensure that the servo port (in this case
d0
) matches the port you are using for your servo. Adjust thesleep
durations and servo positions (100
for open mouth and10
for closed mouth) as needed for your specific setup.And to answer your question, the goal is for artificial intelligence to assist you, but it is a collaborative process where feedback and corrections help improve the AI's performance. Thank you for your patience and input!
I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.