#CSAR Nicer TTS output for MGRS coordinates

This commit is contained in:
Applevangelist 2024-05-06 19:01:02 +02:00
parent 044fb66ca0
commit dd8b2caa24
2 changed files with 77 additions and 12 deletions

View File

@ -295,7 +295,7 @@ CSAR.AircraftType["OH-6A"] = 2
--- CSAR class version.
-- @field #string version
CSAR.version="1.0.22"
CSAR.version="1.0.23"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- ToDo list
@ -735,7 +735,7 @@ function CSAR:_SpawnPilotInField(country,point,frequency,wetfeet)
:NewWithAlias(template,alias)
:InitCoalition(coalition)
:InitCountry(country)
:InitAIOnOff(pilotcacontrol)
--:InitAIOnOff(pilotcacontrol)
:InitDelayOff()
:SpawnFromCoordinate(point)
@ -1239,10 +1239,24 @@ function CSAR:_InitSARForPilot(_downedGroup, _GroupName, _freq, _nomessage, _pla
if not _nomessage then
if _freq ~= 0 then --shagrat
local _text = string.format("%s requests SAR at %s, beacon at %.2f KHz", _groupName, _coordinatesText, _freqk)--shagrat _groupName to prevent 'f15_Pilot_Parachute'
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
if self.coordtype ~= 2 then --not MGRS
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
else
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime,false,true)
local coordtext = UTILS.MGRSStringToSRSFriendly(_coordinatesText,true)
local _text = string.format("%s requests SAR at %s, beacon at %.2f kilo hertz", _groupName, coordtext, _freqk)
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime,true,false)
end
else --shagrat CASEVAC msg
local _text = string.format("Pickup Zone at %s.", _coordinatesText )
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
if self.coordtype ~= 2 then --not MGRS
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime)
else
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime,false,true)
local coordtext = UTILS.MGRSStringToSRSFriendly(_coordinatesText,true)
local _text = string.format("Pickup Zone at %s.", coordtext )
self:_DisplayToAllSAR(_text,self.coalition,self.messageTime,true,false)
end
end
end
@ -1946,23 +1960,28 @@ end
--- (Internal) Display info to all SAR groups.
-- @param #CSAR self
-- @param #string _message Message to display.
-- @param #number _side Coalition of message.
-- @param #number _side Coalition of message.
-- @param #number _messagetime How long to show.
function CSAR:_DisplayToAllSAR(_message, _side, _messagetime)
-- @param #boolean ToSRS If true or nil, send to SRS TTS
-- @param #boolean ToScreen If true or nil, send to Screen
function CSAR:_DisplayToAllSAR(_message, _side, _messagetime,ToSRS,ToScreen)
self:T(self.lid .. " _DisplayToAllSAR")
local messagetime = _messagetime or self.messageTime
if self.msrs then
self:T({_message,ToSRS=ToSRS,ToScreen=ToScreen})
if self.msrs and (ToSRS == true or ToSRS == nil) then
local voice = self.CSARVoice or MSRS.Voices.Google.Standard.en_GB_Standard_F
if self.msrs:GetProvider() == MSRS.Provider.WINDOWS then
voice = self.CSARVoiceMS or MSRS.Voices.Microsoft.Hedda
end
self:I("Voice = "..voice)
self:F("Voice = "..voice)
self.SRSQueue:NewTransmission(_message,duration,self.msrs,tstart,2,subgroups,subtitle,subduration,self.SRSchannel,self.SRSModulation,gender,culture,voice,volume,label,self.coordinate)
end
for _, _unitName in pairs(self.csarUnits) do
local _unit = self:_GetSARHeli(_unitName)
if _unit and not self.suppressmessages then
self:_DisplayMessageToSAR(_unit, _message, _messagetime)
if ToScreen == true or ToScreen == nil then
for _, _unitName in pairs(self.csarUnits) do
local _unit = self:_GetSARHeli(_unitName)
if _unit and not self.suppressmessages then
self:_DisplayMessageToSAR(_unit, _message, _messagetime)
end
end
end
return self

View File

@ -2649,6 +2649,9 @@ function UTILS.SaveSetOfGroups(Set,Path,Filename,Structured)
if group and group:IsAlive() then
local name = group:GetName()
local template = string.gsub(name,"-(.+)$","")
if string.find(name,"AID") then
template = string.gsub(name,"(.AID.%d+$","")
end
if string.find(template,"#") then
template = string.gsub(name,"#(%d+)$","")
end
@ -3881,3 +3884,46 @@ function UTILS.ClockHeadingString(refHdg,tgtHdg)
local clockPos = math.ceil((relativeAngle % 360) / 30)
return clockPos.." o'clock"
end
--- Get a NATO abbreviated MGRS text for SRS use, optionally with prosody slow tag
-- @param #string Text The input string, e.g. "MGRS 4Q FJ 12345 67890"
-- @param #boolean Slow Optional - add slow tags
-- @return #string Output for (Slow) spelling in SRS TTS e.g. "MGRS;<prosody rate="slow">4;Quebec;Foxtrot;Juliett;1;2;3;4;5;6;7;8;niner;zero;</prosody>"
function UTILS.MGRSStringToSRSFriendly(Text,Slow)
local Text = string.gsub(Text,"MGRS ","")
Text = string.gsub(Text,"%s+","")
Text = string.gsub(Text,"([%a%d])","%1;") -- "0;5;1;"
Text = string.gsub(Text,"A","Alpha")
Text = string.gsub(Text,"B","Bravo")
Text = string.gsub(Text,"C","Charlie")
Text = string.gsub(Text,"D","Delta")
Text = string.gsub(Text,"E","Echo")
Text = string.gsub(Text,"F","Foxtrot")
Text = string.gsub(Text,"G","Golf")
Text = string.gsub(Text,"H","Hotel")
Text = string.gsub(Text,"I","India")
Text = string.gsub(Text,"J","Juliett")
Text = string.gsub(Text,"K","Kilo")
Text = string.gsub(Text,"L","Lima")
Text = string.gsub(Text,"M","Mike")
Text = string.gsub(Text,"N","November")
Text = string.gsub(Text,"O","Oscar")
Text = string.gsub(Text,"P","Papa")
Text = string.gsub(Text,"Q","Quebec")
Text = string.gsub(Text,"R","Romeo")
Text = string.gsub(Text,"S","Sierra")
Text = string.gsub(Text,"T","Tango")
Text = string.gsub(Text,"U","Uniform")
Text = string.gsub(Text,"V","Victor")
Text = string.gsub(Text,"W","Whiskey")
Text = string.gsub(Text,"X","Xray")
Text = string.gsub(Text,"Y","Yankee")
Text = string.gsub(Text,"Z","Zulu")
Text = string.gsub(Text,"0","zero")
Text = string.gsub(Text,"9","niner")
if Slow then
Text = '<prosody rate="slow">'..Text..'</prosody>'
end
Text = "MGRS;"..Text
return Text
end