An example of an asynchronous speech macro

Here's a good example of how to use voice synthesis. Originally I created this macro simply because I needed to generate speech to be spoken asynchronously with my running program. I didn't want my program to be otherwise held up by the action of the Speak Text action which doesn't have a way to speak asynchronously. Notice how I use a semaphore to ensure that no two calls to this macro overlap in terms of simultaneous speaking. You can remove that feature if you don't like it. Also notice that I use a bit of arithmetic to alternate the voices between the good male and female voices. Your ear will appreciate this feature! And lastly I have a block which is not expanded here which converts a few words because the macOS speech synthesis sometimes needs "corrections" to its pronunciation. You may not need that. In my case it's just a couple of Search and Replace Variable actions to replace text "X" with text "Y".

Don't forget when you call this macro you must check the action's box to have the macro run asynchronously.

Even if Peter Lewis does add an asynchronous option to the Speak Text action, he probably won't add an option for alternating voices or for linguistic corrections, so this routine will always be useful.

Curiously, the male and female voice synthesizers don't work exactly the same, in terms of pronunciation, so a correction may be needed only for one voice but not the other. But this method covers both cases at the same time.

If you use the variable Trigger elsewhere, as I do, you probably should change the name of that variable to SpeechTrigger, which is more unique.