2 Questions With Scripting

 
#1

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:

Code:


: 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:

Code:


: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.

#2

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?

#3

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.

#4

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

#5

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

Code:


: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

Code:

$z = 1

or

Code:

$z = 0

after what the robot says or does.

#6

There are several problems.

Code:


if($sayEZBWait =("true")


should be:

Code:


if($sayEZBWait =true)


In the line:

Code:


WaitForChange SayEZBWait("text to speech")


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

Code:


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:

Code:


#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:

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:

Code:


$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.

#7

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 EZ-Builder

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

Code:


SayEZBWait("I did not hear you")



7) Press Save to close script editor

8) Press Save to close Settings for Speech Recognition

Here is a tutorial: http://www.ez-robot.com/Tutorials/UserTutorials/178/1

Done.

#8

@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.

#9

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. Smile Super helpful stuff in the tutorials!

#10

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.