
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.
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:
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
@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).
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
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:
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
Ok, let's take the questions one part at a time. I will start with the easiest to answer.
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:
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:
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.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:
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:
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: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:
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:
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:
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:
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?
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
Hi Boris;
I'm sorry, but I don't quite understand what you mean here. Perhaps you could give an example?Hi WBS00001,
now problem: Here my example:
I am searching for a Function what will read a script in a text file.
in the spiegel_answer.txt will be:
i only try to outsource a little bit.
Boris