SO now I have a new 'issue' with voice object

I have modified my warnings method to include a much better description of the problem. I also had to add whether the warning is coming from the port or starboard side.
The problem is that while the app is speaking, the code comes to a halt, and does not continue until after it is done speaking.
My question, should I look at multi-threading this app? I do not notice it so much on my intel I9-12900 machine, but down on the boat, those machines are industrial pc’s with a much slower processor, although they are octa core with multi-threading. So would multi-threading stop that blocking action?
I think I would have to upgrade my lite version to accomplish this.

Here is the bottlekneck;

Var voice As New OLEObject("SAPI.SPVoice")
voice.Voice = voice.GetVoices.Item(1)  // Zira
voice.Volume = 100
voice.Rate = -1
var mWarnMsg as String

if tEID = 0 then
  mWarnMsg = "Port "
else 
  mWarnMsg = "Starboard "
end if

Select Case gid
Case 0
  mWarnMsg = mWarnMsg + "Engine Temperature "
Case 1
  mWarnMsg = mWarnMsg + "Heat Exchanger Temperature "
Case 2
  mWarnMsg = mWarnMsg + "Exhaust Output Temperature "
Case 3
  mWarnMsg = mWarnMsg + "Engine Room Temperature "
Case 4
  mWarnMsg = mWarnMsg + "Oil Pressure "
Case 5
  mWarnMsg = mWarnMsg + "Transmission Pressure "
Case 6
  mWarnMsg = mWarnMsg + "Cooling Water Pressure "
Case 7
  mWarnMsg = mWarnMsg + "Fuel Pressure "
Case 8
  mWarnMsg = mWarnMsg + "Battery Voltage "
Case 9
End Select

if typ = 0 then
  mWarnMsg = mWarnMsg + "low"
else
  mWarnMsg = mWarnMsg + "high"
end if

voice.Speak(mWarnMsg)


Read MS docs. There are flags for some operations, including mixing streams when multiple “speaks” one on top of another.

Thanks for that, unfortunately for me, my ability to read through all of that and understand it has passed.

The slow down is when the object is created. I don’t know enough about XOJO to put that somewhere so that I can reference it without creating it each time. When I change to just System.Speak the slowdown goes away.

I have made a change that seems to have solved it with the exception of the better voice. I made mWarnMsg a global string to use in a thread.

the method called when the warning range is met.

if tEID = 0 then
  mWarnMsg = "Port "
else 
  mWarnMsg = "Starboard "
end if

'mWarnMsg = mWarnMsg + tGaLabel(gid)

Select Case gid
Case 0
  mWarnMsg = mWarnMsg + "Engine Temperature "
Case 1
  mWarnMsg = mWarnMsg + "Heat Exchanger Temperature "
Case 2
  mWarnMsg = mWarnMsg + "Exhaust Output Temperature "
Case 3
  mWarnMsg = mWarnMsg + "Engine Room Temperature "
Case 4
  mWarnMsg = mWarnMsg + "Oil Pressure "
Case 5
  mWarnMsg = mWarnMsg + "Transmission Pressure "
Case 6
  mWarnMsg = mWarnMsg + "Cooling Water Pressure "
Case 7
  mWarnMsg = mWarnMsg + "Fuel Pressure "
Case 8
  mWarnMsg = mWarnMsg + "Battery Voltage "
Case 9
End Select

if typ = 0 then
  mWarnMsg = mWarnMsg + " low"
else
  mWarnMsg = mWarnMsg + " high"
end if

thrdSpeakWarning.Start

In the thread run event

System.Speak(mWarnMsg)
me.Stop

I was able to instantiate the object in the App. But it still stops the program execution. I will continue to tinker with it. I guess that is the nature of an OLEObject. Thanks

So here is what is happening. If all else fails, read the instructions.

Speak(phrase As String, allowInterrupt As Boolean = False)
Uses the built-in speech synthesizer to pronounce the passed text string.
Speak takes a string (or any variant that can be expressed as a string) and uses the Windows or macOS text-to-speech engine to speak the text. The speech is asynchronous, allowing normal program flow to continue. By default, subsequent calls to Speak before the first call has finished will queue up and speak after the completion of the previous call.

The thread didn’t help anything. It works fine from the method. Now if I can just figure out how to change the default voice.

Here is what is working for me. I have changed the OS default voice to Mark. The word ‘high’ sounds better. Thanks for all of the help.

'gid and typ are parameters passed into this method
var mMsg as String
if mRunning = true then
  
  if tEID = 0 then mMsg = "Port " else mMsg = "Starboard "
  
  mMsg = mMsg + tWarnMsg(gid) 'comes from the guages configuration table
  
  if typ = 0 then mMsg = mMsg + " low" else mMsg = mMsg + " high"
  
  System.Speak(mMsg)
end if