Page 1 of 1

Non-blocking wait until revIsSpeaking() is FALSE

Posted: Fri Jul 10, 2015 12:47 am
by deeverd
Hello Forum,

My latest challenge...

I'm trying to get a field to speak, which is easy, and get it to automatically perform other functions as soon as it finishes speaking, also pretty easy. The problem is in figuring out how to do these thing in a non-blocking manner so that the user can stop the speech before it reaches the end.

Here's an example of one of the many scripts I've been using, but which has the disadvantage of forcing one to listen until the speaking is done:

Code: Select all

revSpeak line 1 to -1 of field "audioField"
   wait until revIsSpeaking() is TRUE-- Seems I must do this first, since revIsSpeaking is false at first
   wait until revIsSpeaking() is FALSE
   send "mouseUp" to button "audioQuietButton"
Is there a way of writing this script so that revStopSpeech can be activated at any time during revSpeak? Looking around this forum at some related but different topics, I see advice on using "wait with messages," which seems like it might be a solution, but I've never used that before and am not quite sure how to get that to work with this script.

As always, any suggestions would be greatly appreciated.
All the best,
deeverd

Re: Non-blocking wait until revIsSpeaking() is FALSE

Posted: Fri Jul 10, 2015 12:54 pm
by Randy Hengst
What if you put this code in the field

on mouseUp
if revIsSpeaking() is true then
revStopSpeech
exit mouseUp
else
revSpeak line 1 to -1 of field "audioField"
   wait until revIsSpeaking() is FALSE with messages
end if
end mouseUp


Then you could put this code in the “off” button:
on mouseUp
if revIsSpeaking() is TRUE then
revStopSpeech
end if
end mouseUp

I didn’t have to include this line: wait until revIsSpeaking() is TRUE-- Seems I must do this first, since revIsSpeaking is false at first

I’m using LC6.7.5 on a Mac with OSX10.10.2

be well,
randy

Re: Non-blocking wait until revIsSpeaking() is FALSE

Posted: Fri Jul 10, 2015 5:57 pm
by deeverd
Hi Randy,

Thanks so much!

Putting the "with messages" at the end of the script was the magic I needed.

It also helped to have the "if revIsSpeaking() is true" for the off switch.

Problem solved!

I'm glad my hunch about the "with messages" was right, I just didn't know exactly how or where to use it. I definitely wish there was a resource that showed a bunch of different samples of ways to use various popular commands and functions, besides the LC dictionary, which is good but takes too much knowledge for granted, but something more like a LC thesaurus of common ways of using commands and functions. That would be worth its weight in platinum. Actually, I might post that on the suggestions part of this forum.

Anyway, I really appreciate the help.
Cheers,
Allen