Asked — Edited
Resolved Resolved by WBS00001!

Variables For Speech Reco

Hello,

i am asking me one question:

Have i the possibilty to set a variable in the Speech Commands?

To understand what i mean:

I want to ask the Robot:

Do you like "x" ( and now i can say what i want)

like:

Do you like fishing? Do you like drinking? Do you like flying?

and so on.

and the robot can give an answer: "Yes i like!"

But the important, is to set a variable!

Interresting also:

I will say: My favorite music is "x"

Now the robot will remember the "x" (in this case it will be "Hip Hop")

And the Robot will answer:

Hip Hop (from the variable) i like also!

i think this is more complicate then the first idea, there the speech reco only must understand the start or the end of a sentence.

So it is possible?

Boris

PS: For what i need this Commands:

$SpeechConfidence

and $SpeechPhrase

?

I check out the forum and the manual, but i really find nothing about it.


ARC Pro

Upgrade to ARC Pro

Experience early access to the latest features and updates. You'll have everything that is needed to unleash your robot's potential.

#1  

If you want your robot to remember what you say, and put it into a variable, I believe you have to do what I call "Covering all the bases".

What that means is, in order for the robot to remember your word, you have to add a line in speech recognition which has "Hip hop" in it. The problem with it is, You end up with a command for every type of music.

I don't believe there is another way, though there are things you can do to cut down on how much to enter into speech recognition.

I will provide an example for you soon.

#2  

Here's my example. See the download link below. Make sure it downloads to your "Downloads" Folder. Then extract the files by right-clicking the "AI voice files.zip" and clicking extract, then okay on the following prompt, if one shows.

Open the extracted folder and click the "Ai integrated 1.ezb" file.

In the ARC project, edit each script in the Script manager to match each file location to the downloads folder, with your computer username.

AIvoicefiles.zip

#3  

Hello Technopro!

Really nice idea!

You Demo EZB Project answers me another question what i had... How to make Random Answers! This i got now!

But my first question are not really cleared.

Let´s check only the first problem:

I take your Demo File....

You got there:

Hello Hi Hey

ok, problem this works! But if i say:

Hello Peter Hi Robot Hey variable

this not works!

My idea is, to copy a little bit ALICE to EZB!

So there it is:

<pattern>* CHILDREN</pattern> <template>I HAVE LESS CONTACT TO CHILDREN</template>

So the "star"* is the variable and on every sentence what ends with children the Bot will say this answer.

Do you understand this idea?

But your random test is cool! I will use this also

Boris

#4  

What you are trying to do won't work. The difference is in how speech recognition works with Alice vs ARC.

ARC uses a defined set of items. This is setup by the commands that you have defined in the speech engine. This allows the speech engine to be far more accurate.

Alice is in dictation mode meaning that it tries to pickup anything that is said. This means that it is less reliable, but can handle far more items.

Quote:

I want to ask the Robot:

Do you like "x" ( and now i can say what i want)

like:

Do you like fishing? Do you like drinking? Do you like flying?

and so on.

and the robot can give an answer: "Yes i like!"

"Do you like fishing?" "Do you like drinking?" "Do you like flying?" would have to be setup inside your speech engine for it to recognize this combination of words for ARC to understand. This is why the push for DNS was huge. The cost too was huge.

There are some other ways of doing what you are wanting to do but they all involve programming outside of ARC.

#5  

Hi David,

you see i am still on the Speaking Project!

And i think the ouside programming its to complicted for me, because i told i really don´t know C++ . What a pitty

United Kingdom
#6  

@rentaprinta.

Why not just use the Pandorabot control in ARC and create your own Pandorabot Alice (AIML) files to do what you are asking? It would be a lot easier than programming. Then you can use speech recognition (like David said, less reliable than ARC speech Rec control, but does work), and place control commandsin to the AIML responses to make the robot do things while it speaks.

#7  

Hi Steve,

i build my on pandorabot, but i must say the speech reco there is horrible until not useable. From 0-10 %

The Speech Reco from EZB works to 80-90 %

And i am sitting i a silent room in the front of my mic!

And now image i am standing in my room with open window!

So only EZB will work, thats why i am intressted to make this Speech Commands a little bit more working for a conversation. And not only 100% excat trained sentences.

Boris

United Kingdom
#8  

@Boris.

Fair enough. I understand where you are coming from now.

Other than using a really good speech recognition microphone or headset, and with lots of Windows speech recognition training, then I agree that accuracy will be an issue. That's why I use a remote PC app called "iteleport" which is installed on my iPhone and Windows laptop. Speech recognition is greatly improved using the iPhone, but it does mean pressing a couple of buttons on the iPhone screen.

It's a shame the Dragon idea never took off, as being able to just speak to a robot with excellent results without wearing a microphone or pressing any buttons on a phone to activate and send text, is still something I (and others) would love to have the ability to do, especially where Pandorbot is concerned.

#9  

Hi Steve again!

Yes its me!

I work also with a plantronics headset and its ok. There can be some noises no problem. This everything works!

The only thing what is boring with speech reco, is that i must speak the excat command. After 100-200 Commands, can you remember each command exactly?

Technopro give me a good idea to make random answers.

So it will be not so boring, if i will ask my Inmoov:

How are you?

He can give 20 diffrent answers. Its a beginning. ;-)

Boris

#10  

@rentaprinta I don't quite understand what you are trying to do but I thought I would throw something out anyway. A technique I use is to pause when giving a command at just the right point to allow the Speech Recognition control to work with more than one phrase. In your example with the "do you like" phrase. I would put the phrase "do you like" in as one speech phrase. Then I would pause just a second before saying the last word. For instance: do you like ... fishing

In this way, it will recognize the "do you like" part and respond (perhaps after a bit of a sleep delay to get that last word in before it says anything) but ignore what you say after. If you want it to say something depending on what the last word is you can also put them in the phrase list. I use it mostly for reusing the same robot commands with different robot types or the same words under different contexts.

Context involves using a context variable to allow for different responses depending on what was said first. For instance, using the same words (Flying, fishing, etc.) with different question types, like "have you ever been" in addition to "do you like." Have you ever been ... fishing Have you ever been ... flying Do you like ... flying etc.

There is a lot more to the technique, but I'll stop there since I don't even know if it applies to what you want to do.

#11  

Hi WBS00001!

Nice to hear you!

I check out your ESRP Script and i like it. I understand still not everything but it make my work easier!

I understand your trick with the pause, but it only a trick.

my plan is to have more options for a sentence to say.

I say to the robot (typical conversations):

today moring etc etc etc

answer: it was early?

again with diffrent ending:

today moring etc2 etc2 etc2

answer: it was early?

So the speech recognize "today morning" and know what to answer, nevermind what i say after "today morning"

BUT without this trick pause!

I repeat myself ;-)

#12  

What you are looking for is a natural language processor with object extraction and association or classification. That is a huge project but the good news is that there are many companies working on it. My hope is that it becomes more available to non-programmers. Right now, to use these services requires programming outside of ARC.

#13  

Hello Boris :) I just wanted to mention a couple of things about the ESRP project. The overall concept has greatly expanded since then, but what I put up is still the fundamental concept. I changed a few things in the ESRP project. One is in the call:

CC("SR_Eval",ScriptStartWait)

in the Speech Recognition control, in the "All Recognized" box. I changed it to

CC("SR_Eval",ScriptStart)

I just took out the wait part of the command. I found that, in some cases, waiting would not work properly.

Additionally, I changed the structure of the SR_Eval script so that it checks for an empty string before extracting the first letter.

Finally, I happened to download the project from the cloud and found the Notepad control was full of places with three question marks in a row. Such as:

? ? ?yes? ? ? or ? ? ?no? ? ? that? ? ?s

EDIT Well, I'll be darned! The posting software won't let me put 3 question marks in a row in this post. I put spaces in between the symbols so it would show up as 3 at least.

I don't know if that happened to you, but what is supposed to be there are double quotes ( " ) or single quotes ( ' ). The lines above should be:

"yes" or "no" that's

I have no idea why that happens or what to do about it, but I thought I would mention it.

I have a program that can copy all the phrases and scripts from the Speech Recognition control from a given project and display them. It can also: -Alphabetize them. -Copy the modified phrases and scripts into a project, replacing what is there. -Edit the scripts ... but it is not really designed to do that so it doesn't do things like Key Word highlighting. -Search the phrases -Save what it has copied (and modified) from the project in separate text files.

I want to do more testing on it for a while, but if you're interested, I'll send you a copy when it's done.

#14  

Hello WBS00001,

it sound fantastic what you are doing, i was thinking myself how to copy all phrases from the Speech Control to the scripts. Specially if you want to have a lot of speech commands.

It will be great if you can send me a copy. If you not find my email in my Profil:

kyas@rentaprinta.de

#15  

Hello WBS00001,

another question:

With you ESRP Solution the speech reco is in pause if the roboter talk.

This is great, because i know the problem of hearing himself.

But there an idea:

My robot is talking now a rss feed, but the feed is so long that i reall want to stop the speech, but with a voice command like "stop talking".

HAHA now the problem, the speech reco is in pause.....

Give a possibility to have a master command what works also in pause?

Boris

United Kingdom
#16  

Not an ideal solution, but what you could possibly use in this situation, is to put the stop talking phrase in the "Enable Phrase" and stop talking script in the "Enable Cmd" fields in the voice recognition control. That way, when you say "Stop talking", it will unpause voice recognition and run the stop talking script.

#17  

Hello Steve!

I will try your idea, really its not the best soultion but thanx for your idea.

@WBS00001

also an idea for your ESRP:

If i say "Hello",

its possible to give a random answer from 5 Sentences?

i know there is a command like "Getrandom"

Boris

#18  

@rentaprinta I was thinking about what you said about having a lot of phrases. Even with my program it will still be a lot of effort to copy and paste all the scripts into the correct place in the SR_Eval script. Not to mention generating all the If-statements that will be needed in the various alphabetic sections to make it all work. Tedious to say the least, especially with hundreds of phrases and scripts.

In that regard I believe I can have the program do that automatically so that all you have to do is copy and paste the final result into the SR_Eval script and you're done. It would have the basic structure of the current SR_Eval already built in. In fact, I should be able to have the program do the copy part by just clicking a button in the program as well. Then all you have to do is paste it.

@SteveG That's an excellent suggestion! Thank you. Too bad you can't have more than one phrase in that section.

Another way I was thinking about was to have a psudo-pause. Let the normal pause work as usual, but have a secondary pause that works under script control. The secondary pause would not stop any recognition, but simply not allow anything to go out via the "All Recognized" function in the Speech Recognition control until the special, "stop talking" phrase is spoken. That way you can still use the speech disable phrase as usual. I'm not sure that will work though since there will be a constant stream of chatter coming from the robot as it reads the rss feed, but it's worth a try. Hopefully something spoken directly into the microphone will overwhelm anything coming from the robot or PC. The new plug-in feature might allow for some sort of audio input blocking under script control.

Actually, I believe the current pause function works like that too. I have noticed that noise in the microphone input will sometimes cause something to be recognized. For me, it's usually the word "yes." I think that happens because the noise is usually a hissing sound like the ending of "yes." It blocks input from the microphone, but the recognition function is still working, just that the output is blocked.

In any event your suggestion could be a good work around for now. I may be able to use the script that can be run in conjunction with the Enable Speech function to make it all work out. Interesting problem anyway. Thanks for your input.

EDIT Yes you can have random responses for saying "Hello." You can use the same technique Technopro presented in post #3. There is a way to do it without using an external file, however, if you prefer. But the way he presented is a good one and works quickly in response. Let me know if you would prefer to use the other method I mentioned.

#19  

HI WBS00001,

i like the version from Technopro also, but i think its better to have not to much places where i have information.

I think its better to have the hole conversation in your SR_Eval Script.

So the best way its to have this without external file.

Boris

#20  

Ok, Boris, that's fine. It can all be put in the evaluation script. The usual way I would do that is to have the sentences placed in and array, and the contents called randomly. Like this


DefineArray($HelloResponses,5,&quot;&quot; )
#That sets up an array of 5 strings (0-4)
#Now fill them in:
$HelloResponses[0] =&quot;Sentence one&quot;
$HelloResponses[1] =&quot;Sentence two&quot;
$HelloResponses[2] =&quot;Sentence three&quot;
$HelloResponses[3] =&quot;Sentence four&quot;
$HelloResponses[4] =&quot;Sentence five&quot;

#Then we call for a random number to choose one:
$RandNumber =GetRandomUnique(0,5)  #This gives a number 0 to 5
#But there is no 6th sentence, so we need to change the result to 4:
If ($RandNumber &gt;=5) #I'll explain why I do this below
  $RandNumber =4
endif
#We then use that number to choose which sentence to say:
SayEZBWait($HelloResponses[$RandNumber])

I use GetRandomUnique because it tries to make sure the random number is different from the previous one generated.

There is a bug in the GetRandom functions. They rarely return the highest number in the call. That is the second number (the max value). We only have 5 sentences to deal with so normally the random call would be: GetRandomUnique(0,4)

0-4 =5 numbers. But because of the bug, I make the max value in the call one more than I need. so it is GetRandomUnique(0,5)

That way the number "4" will come up as often as any of the others. But, the high number (5 in this case) will still come up now and then so I change that to 4 if it does. I hope that's clear. If not let me know.

To make that all work out you will also need to initialize the variables used before you can use them. That means you would need to put the first part in the Phrase_Init script. You only want the array to be defined and filled once and the init script is the best way to do that. Unfortunately that means the setup of the arrays would not be all in the evaluation script as you wanted. There are a couple of ways around that.

One way is to define a variable in the Phrase_Init script instead of the array. Like this:


$ArrayDefined =False

That's all, just that variable. Then, in the SR_Eval script you would do the array definition and putting in the sentences as described above. You would use the variable to insure that it is only done once. The first time the SR_Eval script is run, like this:


if ($ArrayDefined =False)
  DefineArray($HelloResponses,5,&quot;&quot; )
  $HelloResponses[0] =&quot;Sentence one&quot;
  $HelloResponses[1] =&quot;Sentence two&quot;
  $HelloResponses[2] =&quot;Sentence three&quot;
  $HelloResponses[3] =&quot;Sentence four&quot;
  $HelloResponses[4] =&quot;Sentence five&quot;
  $ArrayDefined =True
endif

You can put that code in any of several places. One would be right up front:


if($SpeechPhrase !=$NullString AND $SRMode =$DoNotSearch)

  CC($SRName,PauseOn)

  if ($ArrayDefined =False)
    DefineArray($HelloResponses,5,&quot;&quot; )
    $HelloResponses[0] =&quot;Sentence one&quot;
    $HelloResponses[1] =&quot;Sentence two&quot;
    $HelloResponses[2] =&quot;Sentence three&quot;
    $HelloResponses[3] =&quot;Sentence four&quot;
    $HelloResponses[4] =&quot;Sentence five&quot;
    $ArrayDefined =True
  endif

Another would be at the end, using a Goto up front:


if($SpeechPhrase !=$NullString AND $SRMode =$DoNotSearch)

  CC($SRName,PauseOn)

  if ($ArrayDefined =False)
    Goto (SetupArray)
  endif
                 |
    The rest of the normal code    
                 |
:SetupArray
  DefineArray($HelloResponses,5,&quot;&quot; )
  $HelloResponses[0] =&quot;Sentence one&quot;
  $HelloResponses[1] =&quot;Sentence two&quot;
  $HelloResponses[2] =&quot;Sentence three&quot;
  $HelloResponses[3] =&quot;Sentence four&quot;
  $HelloResponses[4] =&quot;Sentence five&quot;
  $ArrayDefined =True
  Return()

  :TheExit
  CC($SRName,PauseOff)

endif

Another place would be in the "Hello" evaluation itself, like this:


  :H_Section
    if($SpeechPhrase =&quot;hello&quot; )
      if ($ArrayDefined =False)
        DefineArray($HelloResponses,4,&quot;&quot; )
        $HelloResponses[0] =&quot;Sentence one&quot;
        $HelloResponses[1] =&quot;Sentence two&quot;
        $HelloResponses[2] =&quot;Sentence three&quot;
        $HelloResponses[3] =&quot;Sentence four&quot;
        $HelloResponses[4] =&quot;Sentence five&quot;
        $ArrayDefined =True
      endif
      $RandNumber =GetRandomUnique(0,5) 
      If ($RandNumber &gt;=5)
        $RandNumber =4
      endif
      SayEZBWait(HelloResponses[$RandNumber])
    endif    
    Goto(TheExit)

However, if there are only going to be 5 sentences ever, it could be just as well to do this:


  :H_Section
    if($SpeechPhrase =&quot;hello&quot; )
      $RandNumber =GetRandomUnique(0,5) 
      If ($RandNumber &gt;=5)
        $RandNumber =4
      endif
      if ($RandNumber =0)
        $HelloResponse =&quot;Sentence one&quot;
      elseif ($RandNumber =1) 
        $HelloResponse =&quot;Sentence two&quot;
      elseif ($RandNumber =2)
        $HelloResponse =&quot;Sentence three&quot;
      elseif ($RandNumber =3)
        $HelloResponse =&quot;Sentence four&quot;
      elseif ($RandNumber =4)
        $HelloResponse =&quot;Sentence five&quot;
      endif
      SayEZBWait($HelloResponse)
    endif
  Goto(TheExit)

That way no array setup is needed.

Hmmm. Maybe I should have presented that method first? :D

#21  

Hi WBS00001,

Cool thanx for your Scrips!

I copy this script because i think it the best place:

:H_Section
    if($SpeechPhrase =&quot;hello&quot; )
      if ($ArrayDefined =False)
        DefineArray($HelloResponses,4,&quot;&quot; )
        $HelloResponses[0] =&quot;Sentence one&quot;
        $HelloResponses[1] =&quot;Sentence two&quot;
        $HelloResponses[2] =&quot;Sentence three&quot;
        $HelloResponses[3] =&quot;Sentence four&quot;
        $HelloResponses[4] =&quot;Sentence five&quot;
        $ArrayDefined =True
      endif
      $RandNumber =GetRandomUnique(0,5) 
      If $RandNumber &gt;=5
        $RandNumber =4
      endif
      SayEZBWait(HelloResponses[$RandNumber])
    endif    
    Goto(TheExit)

but i got everytime a error

(that least one parameter is missing)

for this line: If $RandNumber >=5

What is wrong?

#22  

Ah yes, sorry, I forgot to put the parenthesis in:


$RandNumber =GetRandomUnique(0,5) 
If ($RandNumber &gt;=5) #&lt;--- Right here. The left and right parens
  $RandNumber =4
endif

I found two other errors as well:


DefineArray($HelloResponses,5,&quot;&quot; ) #Should be 5 and not 4
   #Also:
SayEZBWait($HelloResponses[$RandNumber]) #Forgot $ at beginning of HelloResponse.

That's what I get for writing code off the top of my head that I have not actually tested. Please let me know if you find anything else. Thanks.

I'll also make these changes in my previous post.

Here is the whole thing corrected and tested:


  if($SpeechPhrase =&quot;hello&quot; )
    if ($ArrayDefined =False)
      DefineArray($HelloResponses,5,&quot;&quot; )
      $HelloResponses[0] =&quot;Sentence one&quot;
      $HelloResponses[1] =&quot;Sentence two&quot;
      $HelloResponses[2] =&quot;Sentence three&quot;
      $HelloResponses[3] =&quot;Sentence four&quot;
      $HelloResponses[4] =&quot;Sentence five&quot;
      $ArrayDefined =True
    endif
    $RandNumber =GetRandomUnique(0,5) 
    if ($RandNumber &gt;=5)
      $RandNumber =4
    endif
    SayEZBWait($HelloResponses[$RandNumber])
  endif

EDIT I just uploaded a revised version of ESRP. Not too much is changed but what has been changed was needed to prevent some possible faults in the future.

I also added the corrected random sentence script to the H-Section in the SR_Eval script. Additionally I added a few variables to the Phrase_Init script to match the other changes. Tested it out too this time :)

Please download the revised version. It should be ready to go. All you will need to do is change the sentences in the array to what you want them to say.

Oh, and be sure to run the Phrase_Init script one time before you try it out.

#23  

@WBS00001 this is great stuff! Thanks for the lessons. We'er very fortunate you joined our group and are willing to share your knowledge. Us less logical thinkers need masters like you to teach and guide the way. Thank you. Please stick around. :)

#24  

Hello WBS00001,

yes Dave is right! This is really great Stuff! I am still working the hole day on your new script and the Random Funktion is cool!

I learned also something:

I make a new Random Variable for "How are you" with 3 random sentences and it work very well. In the beginning i had some mistakes but in the end i got it!

But some thing is still not understand.

I got it to make a new variable i must write in the "Phrase_Init" $Hello ="hello" - For your old variable for "Hello" $Geht ="test" - For the new variable for "How are you"

to understand here my code in

 if($SpeechPhrase =&quot;wie geht es dir&quot; )
      if ($ArrayDefined =False)
        DefineArray($GehtResponses,3,&quot;&quot; )
        $GehtResponses[0] =&quot;Geht mir super das Wetter bringt mich gut in Stimmung&quot;
        $GehtResponses[1] = &quot;Alles ok&quot;
        $GehtResponses[2] =&quot;K&#246;nnte besser sein aber sonst alles ok&quot;
        $ArrayDefined =True
      endif
      $RandNumber =GetRandomUnique(0,3) 
      if ($RandNumber &gt;=3)
        $RandNumber =2
      endif
      Print($RandNumber)
      SayWait($GehtResponses[$RandNumber])
    endif

so far so good.

But for what is this

$Geht ="test"

i mean the "test" or the "hello"?

So you can see i called my variable "test" and not "Geht" and it still works.

The second question is:

In the Speech Controll is as a script command this line:

if($SRMode =$Search) SayWait("Row, 1") endif

i make new voice commands without this line and it works!

But for what is this line?

Boris

#25  

Another question to the random function:

I want to let the Roboter move a servo, run a script or speak a rss feed on a special random answer.

So my idea is this:

if($SpeechPhrase =&quot;wie geht es dir&quot; )
      if ($ArrayDefined =False)
        DefineArray($GehtResponses,3,&quot;&quot; )
        $GehtResponses[0] =&quot;Geht mir super das Wetter bringt mich gut in Stimmung&quot; +  ControlCommand (windowName, etc etc)
        $GehtResponses[1] = SpeakRSS( &quot;http://www.tagesschau.de/newsticker.rdf&quot;, 0  )
        $GehtResponses[2] =&quot;K&#246;nnte besser sein aber sonst alles ok&quot; + Servo(D14, 25)
        $ArrayDefined =True
      endif
      $RandNumber =GetRandomUnique(0,3) 
      if ($RandNumber &gt;=3)
        $RandNumber =2
      endif
      Print($RandNumber)
      SayWait($GehtResponses[$RandNumber])
    endif

but what you will say, it not works.

Do you have and idea?

Boris

PS:

But really cool Stuff! I take my project years ahead

#26  

@DaveSchulpius Thank you for your kind words. I hadn't really thought of what I posted as a lesson, but I suppose it is in a way. I just like to give details. Sometimes I think I write too much in my posts and may be insulting the intelligence of the person to whom I am addressing, but I'm glad you find it useful. Thanks again for your comment.

@rentaprinta Sorry I haven't answered sooner. I know it is frustrating to not have an answer for hours and hours when you are really into something. But I just got home and read your posts. I wanted to let you know that I will post an answer to your questions in the next couple of hours so you may not see it until tomorrow, since I see it is already late where you are (about 11:30 PM, I believe).

#27  

Hi WBS00001,

no problem,

and its now Sunday 0:02 so don´t worry i will not go sleep until 4-5 oclock in the morning.

And yes, its really a lesson!

i learn a lot!

Boris

#28  

Hi WBS00001,

Another interesting question:

What i can do if i want that 2 or 3 sentence are use the same command.

Do understand here my easy thinking code:

 if($SpeechPhrase =&quot;wie sp&#228;t ist es&quot; and &quot;wie sp&#228;t ist es jetzt&quot;)
SayWait(&quot;Nach meiner Atomuhr ist es jetzt&quot;)
SayWait($minute + &quot;minuten nach&quot; + $hour + &quot;Uhr&quot;)
endif

SO nevermind what i say "wie spät ist es" or "wie spät ist es jetzt" i will give the answer.

I know i can make another entry for "Wie spät ist es jetzt", but if the command script for the voice command is long and i have 3 or 4 variables, in the end the SR_Eval Script will be huge!

So it will be fine so say it simply:

IF you hear this (1a) and this (1b) and this (1c), so do this everytime the same command. Without to have 3 times the same entry?

Or to let the SR_Eval script not to huge, can i leave the script for the voice command outside EZB, like Technopro does it with the Textfile

if($SpeechPhrase ="was sagt der spiegel") ReadScript = C:\spiegel_answer.txt endif

THis will be another idea, there i can copy so much variables i want. And the SR_Eval Script only have the necessary stuff inside.

Boris

#29  

Ok, let's take the questions one part at a time. I will start with the easiest to answer.

Quote:

In the Speech Controll is as a script command this line:

if($SRMode =$Search) SayWait("Row, 1") endif

This is not necessary for the rest of the code to work out. It is in there as a method of searching for a certain phrase in the Speech Recognition control.

In the Phrase_init script is a variable called $SRMode. Right now it is set to $DoNotSearch ($SRMode =$DoNotSearch). This prevents the code for the search function from working. To make it work you would have to change $SRMode to $Search ($SRMode =$Search) in the Phrase_Init script, then run the Phrase_Init script again so that change that will happen. When you say "hello" you will hear "Row 2" spoken as well as one of the randomly chosen phrases. This is because, in what I originally put in, "hello" is in the second row in the Speech Recognition control. If you say "skippy" it will say "row 1" since "skippy" is in row 1.

This is not really helpful with just 2 phrases in the Speech Recognition control, but what if you had 2 hundred? If you had that script in each phrase row, you would be able to find where that phrase is in the list by simply speaking it's name. Then you would have an idea of how far to scroll down to find it. That is why the comment (#1, #2) is also at the beginning. It gives you a row number to go by as you scroll to the proper row in the Speech Recognition control.

Of course, each row would be a little different since each would need a different number. For example the code for row number 145 for phrase number 145 would look like this:


#145
if($SRMode =$Search)
  SayWait(&quot;Row, 145&quot;)
endif

Then, when you say whatever the phrase is in row 145, you would hear "Row 145." To turn this function off you would set the $SRMode variable back to $DoNotSearch and run the Phrase_Init script again.

As I said, none of this is necessary to anything else working so you can ignore it and leave $SRMode set to $DoNotSearch. Or you can delete it all if you wish.

This does bring up an interesting point, however. As I mentioned in another post, I am adding a feature to my external program that works with the data in the Speech Recognition control. The feature will take what is in a given project's Speech Recognition control's phrases and scripts and automatically transform them in a form that can simply be pasted into the SR_Eval script. This will save you the trouble of having to do that manually for each one. I will now also add a check box that will allow for the choice of automatically putting in the search function as well.

Next Question:

Quote:

I got it to make a new variable i must write in the "Phrase_Init" $Hello ="hello" - For your old variable for "Hello" $Geht ="test" - For the new variable for "How are you" .... But for what is this $Geht ="test" i mean the "test" or the "hello"? So you can see i called my variable "test" and not "Geht" and it still works.
At the moment it has no meaning because I did not use it in the H-Section part in the SR_Eval script as I had meant to. This is another mistake on my part.


  :H_Section
    if($SpeechPhrase =&quot;hello&quot; )
              etc.

#What I had meant to put there was this:
  :H_Section
    if($SpeechPhrase =$Hello) #Using the variable instead of the word &quot;hello&quot;

I'll explain. I like to setup variables for things I may use more than once in the script code. In this case it was for the word "hello". By setting a variable to the word, I can use it wherever I like in the code and not have to worry about changes I might make later on.

Using hello as an example. Let's say I put the string "hello" in my code just like that, ie: the word in quotes (that is called a literal string). And I put it in several places in the script. Maybe even in other scripts. Then, at some point, I want to change it to "hi" or "bonjour" instead. Now I will have to find every place I put in "hello" and change it to the new word.

If, instead, I setup a variable like this: $Hello ="hello"

I only have to change the variable and that change will happen automatically in every place I used $Hello. I don't have to change anything else. Just that one variable in Phrase_Init.

That is what I meant to illustrate here by defining $Hello, but I forgot to use it in the code in SR_Eval.

Now, in this particular case there is one more point to cover concerning $Hello. This particular variable is also related to a phrase in the Speech Recognition control. What brought up this whole topic is the fact you cannot use variables in the Speech Recognition control Phrase area. All the phrases must be put in using the actual word. So if a change is made to $Hello, you also have to make it in the Speech Recognition Phrase area. Therefore, if you changed: $Hello ="hello" to $Geht ="test"

you also have to change that in the Speech Recognition control. Where it is "Hello" in the second row in the Phrase area you would put "test". Then in the SR_Eval you would put $Geht, like this:


  :T_Section
    if($SpeechPhrase =$Geht)

Then, when you say "test" into the microphone, the robot would say one of the random sentences.

So, changing $Hello ="hello" to $Geht ="test" doesn't really do anything by itself. You have to make changes in other places as well.

If all that is too confusing right now, just ignore it and put the literal string you want to use in the Speech Recognition control and the SR_Eval script for now.

Next Question:

Quote:

I want to let the Roboter move a servo, run a script or speak a rss feed on a special random answer.

So my idea is this:

Code:

if($SpeechPhrase ="wie geht es dir" ) if ($ArrayDefined =False) DefineArray($GehtResponses,3,"" ) $GehtResponses[0] ="Geht mir super das Wetter bringt mich gut in Stimmung" + ControlCommand (windowName, etc etc) $GehtResponses[1] = SpeakRSS( "http://www.tagesschau.de/newsticker.rdf";, 0 ) $GehtResponses[2] ="Könnte besser sein aber sonst alles ok" + Servo(D14, 25) $ArrayDefined =True endif $RandNumber =GetRandomUnique(0,3) if ($RandNumber >=3) $RandNumber =2 endif Print($RandNumber) SayWait($GehtResponses[$RandNumber]) endif

It would be nice if that would work, but it won't. The reason is because the array can only work with basic types. The Script manual defines the types as:

Quote:

Variable Types Variable types are dynamic by assignment, meaning there is no specific type definition between String, Integer and Floating point.

Examples: String: $str = This is a string String Concat: $str = fu + $bar Integer: $number = 6 Floating Point: $dec = 3.14 Byte: $byte = 0x52 Boolan: $bool = true Result Condition: $result = ($x > $y) Increment numeric: $number++ Decrement numeric: $number Binary Shift Left: $x = 123 << 1 Binary Shift Right: $x = 123 >> 1

So when you try to put in: $GehtResponses[0] ="Geht mir super das Wetter bringt mich gut in Stimmung" + ControlCommand (windowName, etc etc)

It will not take it. It could take the first part like this: $GehtResponses[0] ="Geht mir super das Wetter bringt mich gut in Stimmung"

That would be fine because it is a string. Anything between quotes is a string. But it cannot take ControlCommands or any command. Thus, this is also invalid: $GehtResponses[1] = SpeakRSS( "http://www.tagesschau.de/newsticker.rdf";, 0 )

As is this: $GehtResponses[2] ="Könnte besser sein aber sonst alles ok" + Servo(D14, 25)

To do what you want you would have to resort to using If-Elseif statements like this:


  if($SpeechPhrase =&quot;wie geht es dir&quot; )
    if ($ArrayDefined =False)
      DefineArray($GehtResponses,3,&quot;&quot; )
      $GehtResponses[0] =&quot;Geht mir super das Wetter bringt mich gut in Stimmung&quot;       
      $GehtResponses[1] =&quot;&quot; #Say nothing
      $GehtResponses[2] =&quot;K&#246;nnte besser sein aber sonst alles ok&quot;
      $ArrayDefined =True
    endif
    $RandNumber =GetRandomUnique(0,3) 
    if ($RandNumber &gt;=3)
      $RandNumber =2
    endif
    Say($GehtResponses[$RandNumber])
     
     #New part
    If($RandNumber =0)
       ControlCommand (windowName, etc etc)
    elseif($RandNumber =1)
      SpeakRSS( &quot;http://www.tagesschau.de/newsticker.rdf&quot;;, 0  )
    elseif($RandNumber =2)
      Servo(D14, 25)
    endif  
  endif

Note, I changed the SayWait to Say so that it would be spoken while whatever else is happening is taking place. If you want it to be spoken first, then the action happens, just change it back to SayWait. Also $GehtResponses[1] is a blank (empty) string so that when the Say instruction is executed, nothing will be heard.

In this particular case, since we have to use If-Elseif statements anyway, we could forget the array entirely and do this:


  if($SpeechPhrase =&quot;wie geht es dir&quot; )
    $RandNumber =GetRandomUnique(0,3) 
    if ($RandNumber &gt;=3)
      $RandNumber =2
    endif
  
    If($RandNumber =0)
      Say(&quot;Geht mir super das Wetter bringt mich gut in Stimmung&quot;)
       ControlCommand (windowName, etc etc)
    elseif($RandNumber =1)
      SpeakRSS( &quot;http://www.tagesschau.de/newsticker.rdf&quot;;, 0  )
    elseif($RandNumber =2)
      Say(&quot;K&#246;nnte besser sein aber sonst alles ok&quot;)
      Servo(D14, 25)
    endif  
  endif

On the other hand, if you had many strings and only a few of the possibilities needed commands as well, it could still be useful to use an array.

One other point I need to make here. It's about the $ArrayDefined variable. In order to have all the arrays in the SR_Eval script there will have to be a similar variable for each array. This is because not all will be defined and set with sentences at the same time. As it is now, once one is done, the $ArrayDefined variable will be set to "True". Once that happens, no other array will be defined. This assumes the other arrays will be in different places in the script. So you will have to define and use a variable for each array in the Phrase_Init script.

Additionally, each array must have a unique name since arrays are just like any other variable in that respect. So, you could name the new $ArrayDefined variables according to the array name as in: DefineArray($HelloResponses,5,"" ) DefineArray($GoodbyResponses,5,"" ) DefineArray($YesResponses,5,"" )

The corresponding $ArrayDefined variables could be: $HelloRespArrayDefined =False $GoodbyRespArrayDefined =False $YesRespArrayDefined =False

Then used like this:


  :G_Section
    if($SpeechPhrase =$Goodby)
      if (GoodbyRespArrayDefined =False)
        DefineArray($GoodbyResponses,5,&quot;&quot; )
                     |
        GoodbyRespArrayDefined =True 


  :H_Section
    if($SpeechPhrase =$Hello)
      if (HelloRespArrayDefined =False)
        DefineArray($HelloResponses,5,&quot;&quot; )
                     |
        HelloRespArrayDefined =True 
    
  :Y_Section
    if($SpeechPhrase =$Yes)
      if (YesRespArrayDefined =False)
        DefineArray($YesResponses,5,&quot;&quot; )
                     |
        YesRespArrayDefined =True 

That's one reason it can be best to define the arrays in a separate script all at the same time, but that's a whole other discussion in itself.

Last Question:

Quote:

What i can do if i want that 2 or 3 sentence are use the same command.

Do understand here my easy thinking code:

Code: if($SpeechPhrase ="wie spät ist es" and "wie spät ist es jetzt" ) SayWait("Nach meiner Atomuhr ist es jetzt" ) SayWait($minute + "minuten nach" + $hour + "Uhr" ) endif

First I want to correct one mistake on your part. You may know this and simply put the wrong thing in the code, but, where you say: if($SpeechPhrase ="wie spät ist es" and "wie spät ist es jetzt" )

Should be: if($SpeechPhrase ="wie spät ist es" or "wie spät ist es jetzt" )

Now, let me see if I understand the question. Is it that you do not want to make entries in the Speech Recognition control for other variations of the phrase? In the example, you would have one entry in the Speech Recognition control for the phrase "wie spät ist es" but no entry for "wie spät ist es jetzt". But you still want the SR_Eval script to treat "wie spät ist es" and "wie spät ist es jetzt" the same. Is that correct?

#30  

Hello WBS00001,

now i understand more and more!

Ok the idea with the Variable ($Hello = Bonjour) i understand, yeah is cool like this.

I know the problem from website making. If you want to change a link, you must search the hole site. Today we all use Website with database and it easy to change something, because you only must change the placeholder and everything for this placeholder will be also change!

With the search Function. I know it sound not cool, but why you not write in the Command in the Speech Control which line you will find the Script, then you must also not search.

Forget my last question with the 2 sentence.

Know i understand more and i think its easier to have the script for the voice command ousite from the SR_Eval script.

Like my last post is.

But thanx a lot for you help. Your post are really good and informativ!

Boris

#31  

Hi Boris;

Quote:

With the search Function. I know it sound not cool, but why you not write in the Command in the Speech Control which line you will find the Script, then you must also not search.
I'm sorry, but I don't quite understand what you mean here. Perhaps you could give an example?

#32  

Hi WBS00001,

now problem: Here my example:


if($SpeechPhrase =&quot;was sagt der spiegel&quot;)
ReadScript = C:\spiegel_answer.txt
endif

I am searching for a Function what will read a script in a text file.

in the spiegel_answer.txt will be:


Say(&quot;it works&quot;)
Servo (D0, 35)

i only try to outsource a little bit.

Boris

#33  

Hi Boris;

I'm not sure if you meant this line to be the defining of a variable: ReadScript = C:\spiegel_answer.txt

If so, it should go like this: $ReadScript = "C:\spiegel_answer.txt"

Anyway, there is a script command that can read an entire file at once:
FileReadAll( filename )

Using the $ReadScript from above, It would be used like this: $TheScript =FileReadAll($ReadScript)

So that can read a script from a file. The problem is there is nothing you can do with it. To execute a script, it must be in a script control and then that script control would be run. Unfortunately there is no command or instruction that will put text into a script control. No command that can copy text from a script control either for that matter. There is also no way that I know of that can run a script from a variable.

#34  

Hello Boris;

I just wanted to mention that I have the program working to where it will copy the Speech Recognition phrases and scripts from the Speech Recognition control in an .EZB project file and create the data, in the proper format, for placing those phrases and scripts into the SR_Eval script by pasting it in.

The program has not been tested much yet, so I am hesitant to send it out to be used by others. However, I thought it might be helpful to you if you uploaded a copy of some project of yours that has all the phrases in it. You could save it to the cloud briefly and I could download it for modification and put the result back up to the cloud for you to download.

There is a way to make a project with only the Speech recognition control in it so that you would not have to upload a project with everything else in it just to do this one thing. If you wish to do that I can give you detailed instructions on how to do it. Once you download the project with the modified Speech Recognition control, you can import it into whatever project you like using a blank Speech Recognition control and an a blank SR_Eval script. That can be done using the "Merge" function.

If you don't wish to do this, that that is fine and I completely understand. I just thought I would mention it so you could work with this method for all your phrases as soon as possible. It only takes a few seconds for the program to do this so I can upload the modified project to the cloud within minutes of downloading yours. Assuming nothing unforeseen happens during the conversion process. Which is another reason for me to to it this first time since I can fix whatever goes wrong on the spot.

#35  

Hello WBS000001,

sorry about my delay! I make free on sunday from roboics. ;-)

I really not complete understand what you me with upload and downbload the project, do use thos copy software for the speech commands.

i understand this will copy all speech command from the speech control to a file and then past this to the SR_Eval Script? Right.

So this is interesting if i have a lot of speech commands and now i am starting the SR_Eval Script. So i don´t must write the hole script again to the SR_Eval Script, this will do the Software automaticly?

My problem is i am at the beginning, so my hole command are also in the SR_Eval Script.

But i have a old EZB Project with commands what i really like to copy to the SR_Eval Script i my new EZB Project.

There its interessting. SO i must upload the old project to the EZB Cloud?

To the Question with the scripts in a external text file, i understand that i only can use the textfile for reading a text, not for scripts. Not everything is easy ;-)

But (sorry) back to my idea for variable sentences:

I had and idea for a script like this:

Quote:

if($SpeechPhrase ="wie spät ist es") elseif ($SpeechPhrase ="wie früh ist es") SayWait("Nach meiner Uhr ist es jetzt 13:00") endif

another idea what your are posting:

Quote:

if($SpeechPhrase ="wie spät ist es" or "wie früh ist es") SayWait("Nach meiner Uhr ist es jetzt 13:00") endif

I have saved both commands "wie spät ist es" and "wie früh ist es" in the Speech Control.

But both Scripts will not work. I understand that i can´t make complete diffrent sentences, i think they must start with the same letter, what in this case is the "w".

Or i am completely on the wrong way?

Boris

#36  

Hi Boris, Check out this thread I posted earlier today, it may help you out as well. https://synthiam.com/Community/Questions/8326

#37  

HI bhouston,

thanx for your link, but i want to have it complete opposite.

I say 2 or 3 diffrent sentences and i will hear the same answer.

I german we have a lot of variable to ask something. The sentences starts allmoust the same;

Wie heißt du? Wie ist den Name? Wie wirst du genannt? (how is your name?)

All starts with "Wie" but means the same.

Or:

Wie geht es dir? Wie gehts dir?

(How are you?)

2 only little bit diffrent sentences, but diffrent ... but means the same,

If i will make for every important variable a command, my script will be huge!

The same with "What is the time"

in German

Wie spät ist es Was sagt die Uhr Was sagt die Uhrzeit Wieviel Uhr haben wir

all means "What is the time"

I like this Script "SR_Eval" from WBS00001 for the possibilty to pause and unpause the speech reco. But if i must copy the "What is the time" script 4 times, you can image how long the SR_Eval script will be. And if there is to much inside the script, it will be hard and confuse to work with.

DO you understand the problem?

I don´t want to have 20 or 60 Speech Commands. I think they can be 200 diffrent (incl. variables) Speech Commands. And this will be a big Script.... i must scroll 5 minutes to come to the end ;-)

Boris

#38  

So this might work; Have these different Phrases in Speech Reconition;

Hi Hello Good day etc. and they would all run a script like the following;



$response = GetRandomUnique(0,5)

if($response = 0)
Sayezb(&quot;Hello Boris&quot;)

Elseif($response = 1)
Sayezb(&quot;how's it going&quot;)

Elseif($response = 2)
Sayezb(&quot;what can I do for you?&quot;)

Elseif($response = 3)
Sayezb(&quot;Hello&quot;)

Elseif($response = 4)
Sayezb(&quot;What's up&quot;)

endif


#39  

Hi Boris;

Now it is my turn to apologize for not getting back to you sooner.

Quote:

i understand this will copy all speech command from the speech control to a file and then past this to the SR_Eval Script? Right.

But i have a old EZB Project with commands what i really like to copy to the SR_Eval Script i my new EZB Project.

There its interessting. SO i must upload the old project to the EZB Cloud?

Yes. That is correct.

Be sure to click the box that says "Is public" at the bottom of the upload page so I can access and download it. When I do, I can get all the parts of the Speech Recognition control and format them for the SR_Eval script. I will place an SR_Eval script on the project and paste the modified phrases and scripts from the Speech Recognition control into the new SR_Eval script.

This process will also modify what is currently in the Speech Recognition control with the same phrases that are in it now, but they will be in alphabetical order. In the script part for each phrase will be just a "#" character. There has to be something there to prevent the Speech Recognition control from erasing the phrase. It doesn't always erase it, but it's better to be sure. You can put some text there after the # character to describe what the phrase is for if you like but that is not required.

EDIT If there is already a # as the first character in the first line of the existing script for a given phrase, whatever else is in that line will also be kept as it is because it is already a comment line. That way, if you already have a comment on that first line, it will be transferred to the new Speech Recognition control so you won't have to type it in again.

I am not putting the "search" code for each phrase like I have in the ESRP. If that is desired later I can put it in then.

When I finish the modified project, I will upload it to the cloud for you to download. I will name it differently by adding "_MOD" to the end of the project name. That way there will be no accidental overwriting of the project you sent to me.

Once you have the modified project and verify it works I can give you instructions on how to merge it with another project.

NOTE: It is possible to add what is in the Speech Recognition control in the modified project with what is already in a Speech Recognition control in another project. If you do it that way, however, what you already have in the Speech Recognition control in the other project will not be in alphabetical order after the merge operation. It would be best to add the phrases and scripts you have done recently using the ESRP project to the ones in the old project that you are going to send to me. That way everything will be included in the new SR_Eval script.

#40  

@bhouston

Quote:

So this might work; Have these different Phrases in Speech Reconition;
The problem that Boris faces is that he does not want to have all those phrases and their variations in the Speech Recognition control. He would like to have just one version actually in the Speech Recognition control but somehow have the evaluation script for that one phrase work with all the variations as well.

So far, that simply does not seem to be a possibility because of the way the Speech Recognition control works. It get's good accuracy because it doesn't have to figure out what the speech input means. It only has to match it to one of the phrases in the Phrases area of the control. It then gives an output on what it thinks is the best match.

#41  

Hi again Boris;

I forgot to address the problem you had.

Quote:

if($SpeechPhrase ="wie spät ist es" or "wie früh ist es") SayWait("Nach meiner Uhr ist es jetzt 13:00") endif

I have saved both commands "wie spät ist es" and "wie früh ist es" in the Speech Control.

But both Scripts will not work. I understand that i can´t make complete diffrent sentences, i think they must start with the same letter, what in this case is the "w".

Or i am completely on the wrong way?

This is my mistake again if I posted that you should write it as:


 if($SpeechPhrase =&quot;wie sp&#228;t ist es&quot; or &quot;wie fr&#252;h ist es&quot;)
      #It should have been:
 if($SpeechPhrase =&quot;wie sp&#228;t ist es&quot; or $SpeechPhrase = &quot;wie fr&#252;h ist es&quot;)

Sorry for the confusion. You are correct that both phrases must begin with the same letter for it to work.

Too bad I don't still speak German. I could phrase things so much better for you to understand. I was actually born in Bremerhaven to a German/Dutch mother and an American father. My mother spoke Upper and Lower German and Dutch. I spoke only German until age 6 or 7, then I came to America. I just picked up English (kids seem to be able to do that easily) not long after coming to the USA, and soon after that I could remember no German at all. Not one word. I can't remember any transition period the in languages. I can't even remember my life before age 7. Maybe because it was in a different language, I don't know. I see pictures of me on a farm in Germany then, but I don't remember any of it.

#42  

Hello WBS00001,

BINGO!

thats it!

Ok, now it will be more easier to make speech commands.

I have my 2 -4 or 5 variables what i can say and then the robot will do his job!

I must say, sometimes i can´t really remember how exactly my speech command was. So it will be good to have more possibilities.

Bremerhaven..... An der Nordseeküste, am plattdeutschen Strand, da sind Fische im Wasser und selten an Land.

(At the northsea coast, at the "flat-german" beach, there are the fishes in the water and only sometimes at the beach.)

Ok in German it sounds much more better!

I know Bremerhaven, when i was also a little child i was there and also visiting the submarine in the port. But it was also long time ago.

In the States i was only one time, also when i was a child. Our family was in the 80ties in L.A. I remember some big Palms on the Street, the house cat from our guest family in L.A. and a big birthday party for me in a icecream store.

I got a Congratulation Certificate from the mayor of L.A. - A Lot of Berlin Visitor got this certificate, because WEST-Berlin was and maybe still is a daughter/ partner city of L.A.

But as you read, i am a born Berlin guy, so chaos everyday is also normal for me and this summer we had 3 weeks allmoust everyday 35 centigrade. So only the Palms are missing ;-)

But it´s cool to meet guys from good old germany!

I got some question about the copy programm for the speech commands, but i will write you another post later.

Boris

#43  

Hello WBS00001,

you tipp with the speech variable solved my problem! Thanx again,

you told you have a program what can copy the speech commands into the speech control?

Copy this program also speech command from a list from as word or excel file?

Boris

#44  

Hi Boris;

Quote:

you told you have a program what can copy the speech commands into the speech control?
The program can copy the commands from a Speech Recognition Control in a project to a Script Control, such as SR_Eval.

Quote:

Copy this program also speech command from a list from as word or excel file?
Yes I could make it copy from a Word file. I'm not sure about copying from an Excel file. It would be easiest to copy from a Windows Notepad file, however.

#45  

Hello WBS00001

sorry that our conversations was so abrupt ending

my head was exploding because of the Maker-Faire and the time to finish so much as possible of my Inmoov... but the time where to less so that the inmoov went without arms. But still the Maker-Faire was funny.

I also wanted say thanks to you for you help and support!

In the next days i will make again some programing and sorting the speech reco. So i think i will have some questions to you.

So i whish you a good weekend

and c u later

Boris

PS:

https://www.wevolver.com/gael.langevin/inmoov-robot/inmoov-robot/d5/t3056/

here are some pictures from the Maker-Faire

and here is also a link for a youtube video with my inmoov (the Main Broacast beginns @ 12 min and 35 seconds)

https://www.youtube.com/watch?v=HIVC686hh7o