VoiceWaitUntilDoes does not continue execution

I found something strange:

// this works fine
Say("1");
while( ! VoiceWaitUntilDone( 100 ) ); 
Say("2");

// this doesn't say 2
Say("1");
while( ! VoiceWaitUntilDone( 500 ) ); 
Say("2");

So it's tricky, because you don't want to have a timeout which is too low as it'll constantly be hitting the function, but you also don't want to have a timeout too high, or it won't say anything else at all.

In my actual code, I used a timeout of 5000 milliseconds thinking that it will either finish talking and return 1 or timeout and return a 0 after 5 seconds. It seemed to do the latter but no other Say commands executed after that.

I've replaced all Say calls with this, seems to work for multiple calls to say so far...

function voice_say(text) {
    Say(text);
    while (!VoiceWaitUntilDone( 50 ));
    return;
}

Your code is all wrong. You should NOT be busy waiting for anything.
If you have lots of things to "Say", then instead of doing busy waiting simply pass False in purge parameter (second parameter of Say()) and it will queue all requests and would say everything

As always, READ THE MANUAL,

http://www.amibroker.com/guide/afl/say.html

Say("1", False );
Say("2", False );
Say("1", False );
Say("2", False );

BTW: VoiceWaitUntilDone WORKS perfectly fine. The reason why your example does not work the way you wanted is that you ignored the fact that manual says that default value for purge parameter is true (which means request to Say("2") is purged (removed) as soon as you call Say again).

2 Likes

damn... that one time that I didn't check the function reference...

Thank you good sir.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.