Intel Realsense T265 icon Intel Realsense T265 — Intel RealSense T265 SLAM tracking for ARC way-point navigation with pose streaming, mapping, and low-CPU visual odometry. Try it →
Asked
1 Participant
Inmoov Head Speech Personality Guide

Inmoov Head Speech Personality Guide

Hi - I'm trying to get my InMoov head to do more during speech and need some guidance.

Setup / context:

  • ARC project using the AIMLBot robot skill for conversation.
  • Bing Speech Recognition skill for speech input.
  • Talk servo (mouth) is driven by an IoTiny (EZB) and speech plays from the IoTiny while the mouth moves.
  • I have an ARC JavaScript script attached that was provided/created (by you?), but when I click Start it just sets everything to a default position. I may not be using it correctly.

Problem:

  • I can ask a basic question and it verbally replies (mouth moves), but I cannot get the head servos (neck and eyes) to move randomly during the same speech. I want the neck and eyes to move randomly while the robot speaks.

Here is the script I'm using (ARC JavaScript):

function setNeutral() {
  Servo.setPosition(D0, 90);
  Servo.setPosition(D1, 90);
  Servo.setPosition(D2, 20);
  Servo.setPosition(D3, 90);
}

function setHappy() {
  Servo.setPosition(D0, 100);
  Servo.setPosition(D1, 95);
  Servo.setPosition(D3, 100);
}

function setCurious() {
  Servo.setPosition(D0, 80);
  Servo.setPosition(D1, 110);
  Servo.setPosition(D3, 110);
}

function setSad() {
  Servo.setPosition(D0, 70);
  Servo.setPosition(D1, 85);
  Servo.setPosition(D3, 75);
}

function setSurprised() {
  Servo.setPosition(D0, 110);
  Servo.setPosition(D1, 90);
  Servo.setPosition(D3, 105);
}

function randomSpeakingMotion() {
  Servo.setPosition(D0, Utility.getRandom(75, 105));
  Servo.setPosition(D1, Utility.getRandom(75, 105));
  Servo.setPosition(D3, Utility.getRandom(80, 100));
}

function openMouth() {
  Servo.setPosition(D2, 100);
}

function closeMouth() {
  Servo.setPosition(D2, 20);
}

function detectReaction(text) {
  text = text.toLowerCase();

  if (text.indexOf("hello") >= 0 || text.indexOf("hi") >= 0 || text.indexOf("hey") >= 0) {
    setHappy();
  } else if (text.indexOf("why") >= 0 || text.indexOf("what") >= 0 || text.indexOf("how") >= 0) {
    setCurious();
  } else if (text.indexOf("sorry") >= 0 || text.indexOf("can't") >= 0 || text.indexOf("cannot") >= 0) {
    setSad();
  } else if (text.indexOf("wow") >= 0 || text.indexOf("great") >= 0 || text.indexOf("awesome") >= 0) {
    setSurprised();
  } else {
    setNeutral();
  }
}

var reply = getVar("$BotResponse", "");
if (reply == "") {
  reply = " ";
}

detectReaction(reply);

// Open the mouth before speaking
openMouth();

// Let the head move while speech is active
while (getVar("$IsSpeaking") == "True") {
  randomSpeakingMotion();
  sleep(220);
}

// Close mouth and return to neutral
closeMouth();
sleep(300);
setNeutral();

Additional goal:

  • I'd like to add a personality selector such as: "What kind of personality do you want the head to have: friendly, silly, serious, or more human-like?" and have the head act according to the chosen personality (or be able to switch among them).
  • I also want to be able to ask for things like news and weather and have the robot reply back with that information.

Questions:

  1. Why does the script just set everything to a default when I click Start - am I starting/using it incorrectly within ARC (Robot Skill, script owner, or EZB setup)?
  2. How can I have the neck and eyes move randomly during speech (while the IoTiny is speaking and the mouth servo moves)?
  3. How can I implement selectable personalities (friendly, silly, serious, human-like) so the head behaves differently?
  4. How can I have the bot fetch and speak news/weather responses within the AIMLBot/Bing speech setup?

Thanks - any pointers about where I'm likely going wrong or what additional information I should provide (ARC project setup, Robot Skills used, EZB servo assignments, etc.) would be helpful.



Related Hardware (view all EZB hardware)
EZ-Inmoov Robot Head by EZ-Robot & Gael Langevin
EZ-InMoov Robot Head with Synthiam ARCx: face tracking, speech recognition, Talk Servo jaw motion and AI conversation
Wi-Fi
Servos 8
Camera
Audio
UART ✕
I2C
ADC 2
Digital 8

Related Robot Skills (view all robot skills)
Aimlbot by Synthiam
Localized AIML chatbot with editable AIML files, ez-script support, session memory and ControlCommand API; integrates with speech and robot skills.
Windows Speech Recognition skill: detect custom phrases via PC mic, trigger configurable scripts/actions with adjustable confidence.

ARC Pro

Upgrade to ARC Pro

Experience the transformation – subscribe to Synthiam ARC Pro and watch your robot evolve into a marvel of innovation and intelligence.

Author Avatar
PRO
Canada
Twitter YouTube GitHub
#1  

You’re very close, but there’s a better ARC pattern than putting all of this in one standalone script and pressing Start.

The key issue

Your script is doing two different jobs:

  1. Reacting to chatbot text ($BotResponse)
  2. Trying to animate while speech is in progress ($IsSpeaking)

That usually does not work the way people expect in ARC if the script is launched manually, because:

  • $BotResponse may be empty when you press Start
  • $IsSpeaking only becomes meaningful while ARC is actually speaking
  • If this script runs from a normal script block, it will execute once, set the servos to neutral, and then exit or sit waiting in a way that isn’t tied to the speech lifecycle you want

Best practice

Use the AI/chatbot skill’s response script or the speech skill’s recognized phrase script to trigger the behavior, instead of starting a standalone script manually.

For your setup, the clean architecture is:

  • Bing Speech Recognition sends phrase to AIMLBot
  • AIMLBot generates reply
  • AIMLBot response script :
    • choose personality
    • move head/eyes
    • speak the response
    • optionally animate while speaking

If you want the jaw to move with speech, Talk Servo is the right skill.
If you want neck and eyes to move randomly during speech, that should be handled by a script triggered when the bot is about to speak, not by a script you manually click Start on.


1) Why does it just set everything to a default when I click Start?

Because the script is not connected to a speech event.

Your script begins with:

var reply = getVar("$BotResponse", "");
if (reply == "") {
  reply = " ";
}
detectReaction(reply);

So if $BotResponse is empty, it still falls through and runs your default behavior.

Also, pressing Start on a script is not the same as "run this when the robot talks." It just runs the script once in isolation.

What to do instead

Put the script into one of these places:

  • AIMLBot "Response Script"
  • AIMLBot category response action
  • Bing Speech Recognition "All Recognized Scripts" if you want to forward speech into AIMLBot

If you want the script to run after AIMLBot generates a response, then the AIMLBot response script is the correct place.


2) How can I have the neck and eyes move randomly during speech?

Better way

Don’t use a while ($IsSpeaking == True) loop inside a script launched manually.

Instead, create a short motion routine that is triggered when speech begins, and let it run while speech is active.

Option A: Use a script that starts motion, speaks, then stops

This is the most reliable pattern in ARC.

Example JavaScript:

function setNeutral() {
  Servo.setPosition(D0, 90);
  Servo.setPosition(D1, 90);
  Servo.setPosition(D2, 20);
  Servo.setPosition(D3, 90);
}

function randomSpeakingMotion() {
  Servo.setPosition(D0, Utility.getRandom(75, 105));
  Servo.setPosition(D1, Utility.getRandom(75, 105));
  Servo.setPosition(D3, Utility.getRandom(80, 100));
}

function speakWithMotion(text) {
  var iterations = 15;

  for (var i = 0; i < iterations; i++) {
    randomSpeakingMotion();
    sleep(200);
  }

  Audio.sayEZBWait(text);
  setNeutral();
}

speakWithMotion(getVar("$BotResponse", "Hello"));

Why this is better

  • It doesn’t depend on $IsSpeaking timing
  • It gives you visible motion during the speaking period
  • It is easier to control and debug

Option B: Use a second "background motion" script

If you truly want motion while speech is actively playing, launch a separate motion script from the response script and stop it afterward.

That is more advanced, but it’s the correct pattern if you want continuous motion.


3) How can I implement selectable personalities?

This is a great use case for a global variable and a personality behavior function.

Create a global variable like:

  • $Personality = "friendly"
  • $Personality = "silly"
  • $Personality = "serious"
  • $Personality = "humanlike"

Then branch your motion style and response style based on that variable.

Example personality selector logic

function applyPersonality(text) {
  var personality = getVar("$Personality", "friendly").toLowerCase();

  if (personality == "friendly") {
    Servo.setPosition(D0, Utility.getRandom(85, 100));
    Servo.setPosition(D1, Utility.getRandom(85, 100));
    Servo.setPosition(D3, Utility.getRandom(85, 100));
  } else if (personality == "silly") {
    Servo.setPosition(D0, Utility.getRandom(60, 120));
    Servo.setPosition(D1, Utility.getRandom(60, 120));
    Servo.setPosition(D3, Utility.getRandom(60, 120));
  } else if (personality == "serious") {
    Servo.setPosition(D0, 90);
    Servo.setPosition(D1, 90);
    Servo.setPosition(D3, 90);
  } else if (personality == "humanlike") {
    Servo.setPosition(D0, Utility.getRandom(80, 100));
    Servo.setPosition(D1, Utility.getRandom(80, 100));
    Servo.setPosition(D3, Utility.getRandom(80, 100));
  }
}

How to switch personalities

You can use:

  • a button in Custom UI
  • a speech phrase like "be silly"
  • a chatbot command in AIML
  • a script command

For example, from speech recognition:

setVar("$Personality", "silly");
Audio.sayEZBWait("Okay, I will be silly.");

4) How can I have the bot fetch and speak news/weather?

There are two good approaches:

Best approach in ARC

Use the chatbot only as the conversation layer, and use JavaScript to fetch the data.

Use:

  • Net.hTTPGet()
  • parse the response
  • pass the result to speech

Example weather fetch pattern

If you use a weather API, your script might look like this:

var url = "https://api.weatherapi.com/v1/current.json?key=YOUR_KEY&q=Boston";;
var response = Net.hTTPGet(url, 10000);

print(response);

// Parse JSON depending on the API response format
Audio.sayEZBWait("Here is the weather update.");

For news, do the same thing with a news API.

Important note

AIMLBot itself is not ideal for live web data unless you use it as a trigger.
AIML is better for:

  • personality
  • canned responses
  • scripted phrases
  • local conversation patterns

For dynamic data like weather/news, ARC scripting is the proven method.


What I recommend for your project

Structure it like this

1. Speech recognition

Use Bing Speech Recognition or another STT skill.

2. AIMLBot

Use AIMLBot for personality and conversation.

3. Response script

In AIMLBot’s response script:

  • read $BotResponse
  • look at $Personality
  • animate the head
  • speak the response

4. News/weather

When the user asks for weather/news:

  • route to a script
  • fetch the data with Net.hTTPGet()
  • return it as the bot response

A cleaner example

Here is a much better starting point than the current script:

function setNeutral() {
  Servo.setPosition(D0, 90);
  Servo.setPosition(D1, 90);
  Servo.setPosition(D2, 20);
  Servo.setPosition(D3, 90);
}

function randomSpeakingMotion() {
  var personality = getVar("$Personality", "friendly").toLowerCase();

  if (personality == "silly") {
    Servo.setPosition(D0, Utility.getRandom(60, 120));
    Servo.setPosition(D1, Utility.getRandom(60, 120));
    Servo.setPosition(D3, Utility.getRandom(60, 120));
  } else if (personality == "serious") {
    Servo.setPosition(D0, Utility.getRandom(85, 95));
    Servo.setPosition(D1, Utility.getRandom(85, 95));
    Servo.setPosition(D3, Utility.getRandom(85, 95));
  } else {
    Servo.setPosition(D0, Utility.getRandom(75, 105));
    Servo.setPosition(D1, Utility.getRandom(75, 105));
    Servo.setPosition(D3, Utility.getRandom(80, 100));
  }
}

function speakWithMotion(text) {
  Servo.setPosition(D2, 100);

  for (var i = 0; i < 12; i++) {
    randomSpeakingMotion();
    sleep(200);
  }

  Audio.sayEZBWait(text);
  Servo.setPosition(D2, 20);
  setNeutral();
}

var reply = getVar("$BotResponse", "");
if (reply != "") {
  speakWithMotion(reply);
}

The bigger issue I want to call out directly

Your current design is mixing:

  • chat logic
  • voice recognition
  • speech synthesis
  • animation

That can work, but in ARC it’s much more stable when you split them into separate robot skills and connect them with ControlCommand() and global variables.

That is the proven ARC way to build conversational robots.


What I need from you to give you the exact fix

Can you tell me:

  1. Where exactly is this script located right now?

    • AIMLBot response script?
    • Bing Speech "All Recognized Scripts"?
    • standalone script skill?
    • a Custom Movement/Auto Position action?
  2. Which servos are on which ports?

    • neck
    • eyes
    • jaw
  3. Do you want the head motion to happen

    • only while speaking
    • while listening too
    • both
  4. Do you want the personality to be selected

    • by voice
    • by UI button
    • automatically based on the topic

If you want, I can help you build this into a proper ARC workflow using:

  • Bing Speech Recognition
  • AIMLBot
  • Talk Servo
  • JavaScript
  • personality selector
  • weather/news lookup
I am a customer support AI and still learning. Please verify important answers in our support documentation. For advanced AI features, use the AI Script Agent built into ARC.