Germany
Asked — Edited

2 Questions With Scripting

Hello from Germany, I have 2 problems when programming scripts and hope someone can help me.

Problem 1: Speech Recognition at Low Confidence, I want that the robot at low Cinfidence says he did not hear me, for that I have written the following script, which unfortunately will cause it always says he did not understand me correctly:


: start

WaitForChange($SpeechConfidence)

$SpeechConfidence < = ( 0.69 )

sayEZBWait("Entschuldigung, ich habe Dich nicht richtig verstanden")

GoTo(start)

Problem 2: I would like to start a script when the robot speaks, this, I wrote the following script but does not work:


:start

$sayEZBWait = "eingabe"

WaitForChange SayEZBWait("text to speech") 

if(SayEZBWait = ("true")

$z = 1

ElseIf (SayEZBWait = ("false")

$z = 0

EndIf 

if($z = 1)

ControlCommand("Script Manager", ScriptStart, "Start Körpersprache")

ElseIf ($z = 0)

ControlCommand("Script Manager", ScriptStart, "Stop Körpersprache")

endif

Goto (start)

Thanks for your Help

*edited by DJ Sures to put code in proper UBB tags so people can read it.


ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

#1  

What language do you have it set to? If is you English, which I think is the default setting, I would imagine speaking German would not work.

Can you upload your project here?

#2  

The problem with the second script is the $sayEZBwait variable is never used. The command SayEZBwait() doesn't make cause the variable to change as far as i know.

Germany
#3  

Thanks for the replies, yes I use as the system language German and so far has indeed everything works, also the voice control. I just uploaded my project. Are, however, difficult because much is German.

Omnibot2000.EZB

at MazeHorizon0-Techno

Can you give me a hint how I change the script must to use the variable?

Thank you

#4  

@lizpoir You can skip out on the whole first half as its not necessary. For that script use:


:start

if ($z = 1)

  ControlCommand("Script Manager", ScriptStart, "Start Körpersprache")

ELSEif ($z = 0)

  ControlCommand("Script Manager", ScriptStart, "Stop Körpersprache")

endif

Goto (start) 

And everywhere you want to have the variable change, simply add

$z = 1

or

$z = 0

after what the robot says or does.

#5  

There are several problems.


if($sayEZBWait =("true")

should be:


if($sayEZBWait =true)

In the line:


  WaitForChange SayEZBWait("text to speech") 

You cannot wait for a function. You have to wait for a variable to change, such as:


WaitForChange($sayEZBWait)

SayEZBWait() is a function. All it does is say the text in the argument (the quoted words in the parenthesis).

What you actually want is:


#Problem 1
: start
WaitForChange($SpeechConfidence)

if($SpeechConfidence < =  0.69 )
  sayEZBWait("Entschuldigung, ich habe Dich nicht richtig verstanden")
endif

GoTo(start)

For problem 2. The robot only speaks when an SayEZBWait() instruction is executed. That means wherever you put in the SayEZBWait instruction in the program. So, right after you do that you would then put in the script lines you want executed or a call to them via a CommandControl instruction or a Goto() if it is all in one script. There are various ways to do that.

What you seem to want is a universal way to do it by waiting for something to change when the robot says something. One way to do that would require a call the SayEZBWait() instruction by a CommandControl() instruction. To do that you put the CommandControl() instruction in a separate script somewhere and call it. But you will have to use the CommandControl() instruction every time you want to execute a script when the robot speaks. You would no longer use the SayEZBWait() instruction directly.

Something like this:

First, write what you want to be run in a blank script with only that routine in it and name whatever you like, let's say you name the script "RobotSpeaks". In RobotSpeaks would be the following lines of code:


SayEZBWait($PhraseToSay)
#Here you place the script instructions you want to run when the robot speaks.
#NOTE: You can also place those instructions before the SayEZBWait line if you 
#want the code to execute before the robot says the text. If you want it to say the
#text at the same time it executes the script code then use SayEZB() instead of
#SayEZBWait.

Then you call RobotSpeaks from your main script like this:


$PhraseToSay ="Test" #Whatever you want the robot to say.
CommandControl("RobotSpeaks",ScriptStartWait)

I understand that may not be all clear so feel free to ask questions.

PRO
Synthiam
#6  

This is even easier and only requires one line of code. Here is every step you need to take to make it happen.

  1. Load ARC

  2. Press Project -> Add Control from top menu

  3. Select AUDIO category and add Speech Recognition

  4. Locate speech recognition control and press GEAR icon (that accesses configuration screen)

  5. Locate Low Confidence script and press the EDIT button on the far right to open multiline editor

  6. Enter this code


SayEZBWait("I did not hear you")

  1. Press Save to close script editor

  2. Press Save to close Settings for Speech Recognition

Here is a tutorial: https://synthiam.com/Tutorials/UserTutorials/178/1

Done.

United Kingdom
#7  

@lizpoir.

This is the first time I have looked at the forum all day, and just saw your threads do see that you've had some great help already. Just to add to DJ's last post, I also wrote a speech recognition tutorial that you should find helpful.

Speech Recognition Tutorial.

PRO
Synthiam
#8  

To second Steve - you will find access to tutorials related to any control by pressing the ? (question mark) on the control. The ? (question mark) is located next to the X (close) button.:) Super helpful stuff in the tutorials!

#9  

Quote:

Locate Low Confidence script and press the EDIT button on the far right to open multiline editor
Well darn. I feel stupid. I've probably run across that too. Totally forgot about it.

#10  

Quote:

Well darn. I feel stupid. I've probably run across that too. Totally forgot about it.
Happens to me all the time. There is SO much functionality in ARC that I can't keep up with it all and come up with complex solutions to simple problems that have already been solved.

Alan

PRO
Synthiam
#11  

lol - don't feel dumb - tell you a story that happens often. I think of a great idea, load ARC source code and begin creating it.... only to realize that it's already there! Happens all the time lol

that's why the plugin system comes in handy:D

Germany
#12  

I have apparently made after a rather silly question or I did not realize that there is such a simple solution to my problem 1 which is already integrated into the ARC.

In Problem 2 I test tonight and give you a return info.

Thanks once.

Germany
#13  

Okay, i have testet, Problem 1 is solved, many thanks at all.

Problem 2: @MazeHorizon0-Techno Thank you for your script. Really it does not work, I have made the following changes: $z = "Eingabe"

:start

WaitForChange ($z)

if ($z = 1)

ControlCommand("Script Manager", ScriptStart, "Start Körpersprache")

ELSEif ($z = 0)

ControlCommand("Script Manager", ScriptStart, "Stop Körpersprache")

endif

Goto (Start)

Now it works, but actually I wanted to have it even easier. I did not want to manually set the variables in all voice instructions.

@WBS00001

Thanks for your help, but I think you have not understood what I want or I interpret your help wrong.

I want to start a script automatically when the robot speaks. Just as in the script of "MazeHorizon0-techno" but before and without entering them manually after each "SayEZBWait" command variable.

Greetings Sven

PRO
Synthiam
#14  

Why are you not following the tutorial? Simply add ONE single command to the Confidence script. The additional logic of a loop, second script, etc is inefficient and introduces room for error. Specifically since it doesn't make any sense.

Revisit the previous posts of this forum and follow the tutorial.

#15  

@lizpoir

Quote:

I want to start a script automatically when the robot speaks. Just as in the script of "MazeHorizon0-techno" but before and without entering them manually after each "SayEZBWait" command variable.
That's the problem. There is nothing that executes automatically when the robot speaks. The robot can speak one of two ways:

  1. Executing a SayEZB() or SayEZBWait() instruction.
  2. Playing a selection from a Soundboard

To my knowledge, there is nothing which triggers when either of those things happen. And, in a script, they can only happen when you put in a line of code which will send something to the robot for it to say. There is nothing which monitors when the robot is speaking and can be used to trigger something else at that moment. You have to do that with other coding that you enter yourself. My example was one way to do that.

#16  

Quote:

That's the problem. There is nothing that executes automatically when the robot speaks. The robot can speak one of two ways:

  1. Executing a SayEZB() or SayEZBWait() instruction.
  2. Playing a selection from a Soundboard

To my knowledge, there is nothing which triggers when either of those things happen. And, in a script, they can only happen when you put in a line of code which will send something to the robot for it to say. There is nothing which monitors when the robot is speaking and can be used to trigger something else at that moment. You have to do that with other coding that you enter yourself. My example was one way to do that.

Actually....

Two ways. if the only sound the EZ-B will be making is speech (ie, not playing MP3s) you can add a "sound servo (EZB Playback)" object to the project. Don't define a servo for it. Than have a script that waits for change in the $Soundv4Value variable, and it will execute whenever that value changes. I use the following script to vary the brightness of an LED when my Roli is speaking or playing music:


$Soundv4Value = 0
:loop
waitforchange($Soundv4Value)
PWM(D11,$Soundv4Value)
goto(loop)

If you will have other sounds, but only want to react to speech, you can similarly add a "talk servo" object. This one doesn't have a default variable you can act on, but if you define the servo as a Virtual servo, and then do a WaitForServoMove (servoPort, [timeout MS]) using the virtual servo port you defined as the servo port, the script will trigger any time the EZ-B speaks.

Alan

Germany
#17  

@ DJ I follow the tutorial, but for Problem 2 there is no tutorial.

@ WBS00001 Thanks, now i have understand

@thetechguru Thats a good idea, i will testing.

#18  

@thetechguru Excellent! I had no idea that was the case. Have not had the need for the Sound servo component as yet. Great tricks and seems to be just what is needed in this situation. Thanks so much for the info. Definitely add that to my repertoire.

We need a "Tips and Tricks" section for this sort of good stuff. Things that are not broad enough for a full blown tutorial but really handy nonetheless.

#19  

I have a folder of bookmarked threads with little tips, links to hardware or software I might need in future builds, etc.. Of course, that only helps me;)

Alan

Germany
#20  

Alan, which sound servo do you use? There are yet no servo function operates at the SayEZB command. It's all the talk Servo, but who has no variable.

i think im to stupid.

Sven

#21  

Sound servo (EZB Playback)

See screen shot. The one I use is circled.

User-inserted image

Germany
#22  

Dont work, level and Variable are ever 0

Germany
#24  

Yes, i have ARC from today

$Soundv4Value is ever 0

#25  

I'll check my project this weekend and make sure it still works and see if I missed anything in my instructions.

Alan

Germany
#26  

Alan, Thanks for your help

Sven

#27  

I haven't had a chance to look at/ test my project yet, but thinking about it, I think you will need to define a virtual servo and define the range of motion for the variable to populate.

I should be able to confirm it tonight or first thing tomorrow.

Alan

#28  

Well, it appears that the functionality was broken sometime in one of the last few releases.

@DJ, if you are watching this thread, see my public project "myroli-mkii".

On the second virtual desktop is a sound servo (EZB) object defined as a virtual servo. The $Soundv4Value variable used to change whenever I used either the speech test script or played the song in the Soundboard (EZB) on desktop 1. If you run the Sound LED script while any sound was playing, it would brighten and darken an LED on port D11.

I tested this after you made the fix Steve references above with the misnamed sound servo objects and it worked, so sometime between then and now it has stopped working.

In fact, Sound servo (EZB) does not appear to be working at all. I redefined it from the virtual port to one of the claws, and it does not react to any EZ-B sound.

Talk servo does work correctly.

Alan

Germany
#29  

The sound with the sound servo I once abandoned. But now I have the next problem, it is not possible to give RSS Feeds on the ECB again. The SpeakRSSEZB command does not exist. Have I missed something here?

Greetings from Germany and sorry for my many questions. Sven