Speech

Documentation. First post is always kind of manual page, being continuously updated by author. Following posts are discussion about the topic.
Post Reply
admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Speech

Post by admin » 19 Sep 2015, 22:14

This one is quite simple: LuaMacros can talk to you! Sometimes you want some confirmation that macro was triggered, code was done, mode was changed, whatever. When interfacing Xplane you can use command lmc_xpl_text which will show text at simulator's screen.
But now (version 0.1.0.225 and later) you can also use command lmc_say and some nice lady from windows will talk to you :-).
You can try yourself with code

Code: Select all

lmc_say('Hello world')
No big deal - as I said, this is simple but useful.

One more script for Xplaners, little more complicated. This will call selected radar altitudes when getting close to ground. Now it talks in both way, but comment out one of the lmc_say commands if you need only landing notifications:

Code: Select all

gLastRAltInterval = 0
gRAltCalls = {5, 10, 20, 50, 100, 200, 500}

function getRAltInterval(value)
  if value < gRAltCalls[1] then
    return 0
  end
  for i = 1,#gRAltCalls do
    if value <= gRAltCalls[i] then
      return i-1
    end
  end
  return #gRAltCalls
end

function checkRAlt(cra)
  curIndex = getRAltInterval(cra)
  if gLastRAltInterval ~= curIndex then
    if gLastRAltInterval > curIndex then
      lmc_say('' .. gRAltCalls[gLastRAltInterval])
    else
      lmc_say('' .. gRAltCalls[curIndex])
    end
    gLastRAltInterval = curIndex
  end
end

lmc_on_xpl_var_change('sim/cockpit2/gauges/indicators/radio_altimeter_height_ft_pilot', checkRAlt, 1000)
Disclaimer: For the speech engine Microsoft speech API is used. I have neither idea nor tests about compatibility. It works at my Windows7 64bit and should work almost everywhere (Vista+ I suppose), but this is some COM magic so don't be upset if your computer keeps silent...
Petr Medek
LUAmacros author

Post Reply