Asked

Problem With A Script And Bingspeech In Javascript

I am transitioning from EZ-Script to JavaScript because I heard that ARC X will no longer support EZ-Script. I've been struggling for hours with simple tasks that don't seem to work. I plan to write more complex code later. Here's what I want the code to do:

JD should introduce himself, and I will respond. JD should recognize my response and reply accordingly. If JD can't recognize what I'm saying, it should start the process again. Could you please review the code below?

//**************   Start Here  ***************
Audio.sayWait("Hi, my name is JD"); // JD's introduction
sleep(500);
ControlCommand("Bing Speech Recognition", "StartListening");
sleep(3000);
print("Answer is: " + getVar("$BingSpeech")); // For testing purposes

if (getVar("$BingSpeech") == "Hi JD" || getVar("$BingSpeech") == "Hello JD") {
    sleep(1000);
    Audio.say("Hello Philip");
} else {
    Audio.say("Sorry, I don't understand. Can you say that again?");
}

The syntax seems correct since there are no errors, but the problem is that the $BingSpeech variable holds the previous input instead of the current one. For example, if I start the script a second time and say "Hello JD," the print statement displays "Hi JD" because I said "Hi JD" the first time. It seems that the $BingSpeech variable retains the last input. Perhaps clearing the variable would help, but I'm not sure how to do that.

I hope my explanation is clear. Additionally, could you modify the script to include a loop when the response is not "Hello JD" or "Hi JD"? I tried using a goto statement, but that's specific to EZ-Script.


Related Hardware JD Humanoid

ARC Pro

Upgrade to ARC Pro

Elevate your robot's capabilities to the next level with Synthiam ARC Pro, unlocking a world of possibilities in robot programming.

PRO
Synthiam
#10  

Haha - keeping up with changing technologies to maintain Synthiam ARC ages me more:D

PRO
Germany
#11  

I feel old  too, grew up with basic and z80:)

PRO
Synthiam
#12  

z80! now you're talking my language I didn't know much about the z80 because we were an Apple II family, so it was a 6502 assembler I learned as a kid. We had this book with all the functions available for the WOZ. I would make small programs using it. That was my introduction to assembly. After that, I got into Pascal, then Turbo Pascal on the PC. And finally, C. I avoided C for a long time as a teenager because all the books and examples were "Business related stuff" or "utilities". But Pascal was for games and graphics, etc... Anyway, I didn't really touch assembly much until I started EZ-Robot and needed to program the microcontrollers and write the firmware.

My most recent Z80 experience was working with the NABU computer. I did a ton of assembly with that and was able to mix C and assembly together for several of the projects I worked on. It was fun! I haven't done anything with it since last May. I might do something with it again before summer hits, but we have a lot going on here, so my free time is a luxury, haha.

But, back on topic for this thread and how the ControlCommand works with robot skills running in their threads. One of the features that we were writing into ARCx was a new scripting engine that would return values from controlcommand(). I have been getting several ARCx features moved to ARC while we truck away at it. I'll have that new script engine added to ARC. I believe we have a code branch with it. It's been tested so it should be simple enough to merge into the next update. That means you could do something like this...

var x = controlCommand("Open AI GPT", "getResponse", "Hi there, how are you?");
print("Response was " + x);

Fewer variables were used, and more real-time responses from robot skills were needed. This doesn't justify the linear programming IF/ELSE mentioned earlier, but it does make some of the robot skills' functions a little easier to run linearly, such as a response from the GPT.

PRO
Germany
#13  

I remember having made very small programs in assembly (I preferred BASIC) on the Z80 and on Cyber 205 as well for a training at CDC. Ho god, that doesn't exactly make us younger,Time flies, doesn't it?

back to the previous thread. Many things to try. the functions examples of athena, the Conversational Menu looks damn good!, your example with var x. I used  pandora already, it was ok even with some funny answers! i will finish the built of Jd+chassis and check then the Open AI GPT skill. navigation will come later.