Text To Speech

Posted by Rene on Mon 25 Dec 2017 10:24 PM — 3 posts, 15,532 views.

#0
I've been playing with the text to speech code:


assert (package.loadlib ("luacom.dll","luacom_open")) ()
  talk = assert (luacom.CreateObject ("SAPI.SpVoice"), "cannot open SAPI")
talk:Speak ("%1!")


I use it to announce events I want to hear even while in a different window, yet I find it lags MUSH on me, has anyone had similar experiences and might have a suggestion how to avoid this?
Amended on Mon 25 Dec 2017 11:23 PM by Nick Gammon
Australia Forum Administrator #1
Don't create the object each time, that would be slow. Create the SAPI object ("talk") once when you start the client, and just do talk:Speak when you want to say something.
Australia Forum Administrator #2
You could probably do this:


if not talk then  -- load if not already loaded
  assert (package.loadlib ("luacom.dll","luacom_open")) ()
  talk = assert (luacom.CreateObject ("SAPI.SpVoice"), "cannot open SAPI")
end -- if not loaded

talk:Speak ("%1!")