If your script does not use any GUI add-on, such as REXX GUI, then you can't use asynchronous operation with SpeechSpeak(). SpeechSpeak() must fully complete its speaking of the text before it returns.

You also do not need to supply any window or messageNum arguments to SpeechOpen().

Here then is an example of speaking some text:

OPTIONS "C_CALL"

/* Load REXXSPEECH.DLL and register all its functions. */
LIBRARY rexxspeech

/* Get user's choice of speech engine, and save its ID. */
id = SpeechVoiceDlg()
IF id == "" THEN DO
   SAY "Error getting speech device ID, or user cancelled"
   RETURN
END

/* Open that speech engine, and save its voice parameter. */
voice = SpeechOpen(id)
IF voice == "" THEN DO
   SAY "Error opening/initializing the speech voice!"
   RETURN
END

/* If desired, you can call SpeechVolume, SpeechPitch,
 * or SpeechSpeed here, to set (or query) the settings
 * for volume, pitch, and speed, respectively.
 */

/* Speak some text. */
error = SpeechSpeak(voice, "Hello world.")
IF error \== "" THEN SAY "Error speaking text:" error

/* If desired, you can make further calls to SpeechSpeak here. */

/* Close the speech engine. */
SpeechClose(voice)