We are about to switch to a new forum software. Until then we have removed the registration on this forum.
i found a sketch that has the pc say whatever i want but the issue is that it will keep saying over and over, also i notice that it is very slow at processing and while the pc says anything the video output becomes slow or freezes for like 500ms which is crazy
import guru.ttslib.*;
TTS Server;
void setup() {
size(100, 100);
Server = new TTS();
}
void draw() {
}
void mousePressed() {
Server.speak("Good day?");
}
now if i was to use a function inside draw and every time that functions condition is met the pc will say what ever is on that function right? but the issue is that while that function is being used the pc will keep saying the same thing over and over so HOW can i get it to say what ever JUST ONCE ?
Answers
Does it work just once in draw? Is there a Server.stop() thing?
im not sure if there is such functions i really hate how processing kinda hides everything deep in folders, Arduino's libraries are clear and fast to find including all their header and cpp files, trying to do the same with java in processing is a headache
import guru.ttslib.*;
is not Processing.http://local-guru.net/blog/pages/ttslib
Library: http://www.local-guru.net/projects/ttslib/ttslib-0.4.zip
Source code: http://www.local-guru.net/projects/ttslib/ttslib-src-0.4.zip
Last modified: 3/10/2013 9:17 AM
I just tried your sketch and the example from the library and worked worked fine.
@AverageJoe okay so i tried your code and it did not work so my new question is where do i place this function from draw
if i have multiple tabs and in every tab i have a speak function
Try using the
mouseReleased
method instead ofmousePressed
Could there be a bad library install or something? I don't understand why a thread wouldn't stop looping a call.
@quark i dont see no diff in using one or the other, although i do know their is a diff
@AverageJoe i dont think so because aside from the modification im looking for everything works fine
if i use this
but if i use this
it will keep saying as long as there is no face "good night, good night, good night, good night" lol just haywire and the same for if it sees a face "good day, good day, good day"
So what you want is, you only want it to say "good night" when the face goes away, and you only want it to say "good day" when the face turns up?
In that case you'll need to change your logic a bit and detect if faces.length changed value in an iteration.
@colouredmirrorball no sorry, but you missed understood. i want it to say it once not over and over while any of those statements are true or high
That's exactly what I tried to do. Not sure if it works though. Line 2 of my code should ensure the loop only runs when the amount of faces is different. Assuming of course you want to say a message as soon as a face (dis)appears.
yes this is what i like BUT only to be said once not over and over as it is in the draw "which just loops over and over as long as that function is running"
Yes. The trick is to rewrite the function so that it does not run if it shouldn't, even if it got called from draw(). Or if you don't like that, find some logic that doesn't call the function from draw. This is usually done by boolean flags. Is a face detected? Yes? Have you already called the function?
-> yes: don't call it again -> no: call it and make sure you don't call it again (set a boolean to false).