MSRS additions

This commit is contained in:
Applevangelist 2024-01-07 13:25:32 +01:00
parent 406dbb707a
commit 06c3ca0079
5 changed files with 42 additions and 23 deletions

View File

@ -1416,6 +1416,7 @@ function AWACS:SetTacticalRadios(BaseFreq,Increase,Modulation,Interval,Number)
if self.PathToGoogleKey then if self.PathToGoogleKey then
--self.TacticalSRS:SetGoogle(self.PathToGoogleKey) --self.TacticalSRS:SetGoogle(self.PathToGoogleKey)
self.TacticalSRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey) self.TacticalSRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey)
self.TacticalSRS:SetProvider(MSRS.Provider.GOOGLE)
end end
self.TacticalSRSQ = MSRSQUEUE:New("Tactical AWACS") self.TacticalSRSQ = MSRSQUEUE:New("Tactical AWACS")
end end
@ -2104,9 +2105,10 @@ function AWACS:SetSRS(PathToSRS,Gender,Culture,Port,Voice,Volume,PathToGoogleKey
if self.PathToGoogleKey then if self.PathToGoogleKey then
--self.AwacsSRS:SetGoogle(self.PathToGoogleKey) --self.AwacsSRS:SetGoogle(self.PathToGoogleKey)
self.AwacsSRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey) self.AwacsSRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey)
self.AwacsSRS:SetProvider(MSRS.Provider.GOOGLE)
end end
-- Pre-configured Google? -- Pre-configured Google?
if self.AwacsSRS:GetProvider() == MSRS.Provider.GOOGLE then if (not PathToGoogleKey) and self.AwacsSRS:GetProvider() == MSRS.Provider.GOOGLE then
self.PathToGoogleKey = MSRS.poptions.gcloud.credentials self.PathToGoogleKey = MSRS.poptions.gcloud.credentials
self.Voice = Voice or MSRS.poptions.gcloud.voice self.Voice = Voice or MSRS.poptions.gcloud.voice
self.AccessKey = AccessKey or MSRS.poptions.gcloud.key self.AccessKey = AccessKey or MSRS.poptions.gcloud.key

View File

@ -411,26 +411,36 @@ function FLIGHTCONTROL:New(AirbaseName, Frequency, Modulation, PathToSRS, Port,
self:SetRunwayRepairtime() self:SetRunwayRepairtime()
self.nosubs = false self.nosubs = false
-- Set SRS Port
self:SetSRSPort(Port or 5002)
-- Set Callsign Options -- Set Callsign Options
self:SetCallSignOptions(true,true) self:SetCallSignOptions(true,true)
-- Init msrs queue. -- Init msrs queue.
self.msrsqueue=MSRSQUEUE:New(self.alias) self.msrsqueue=MSRSQUEUE:New(self.alias)
-- Init msrs bases
local path = PathToSRS or MSRS.path
local port = Port or MSRS.port or 5002
-- Set SRS Port
self:SetSRSPort(port)
-- SRS for Tower. -- SRS for Tower.
self.msrsTower=MSRS:New(PathToSRS, Frequency, Modulation) self.msrsTower=MSRS:New(path, Frequency, Modulation)
self.msrsTower:SetPort(self.Port) self.msrsTower:SetPort(port)
self.msrsTower:SetGoogle(GoogleKey) if GoogleKey then
self.msrsTower:SetProviderOptionsGoogle(GoogleKey,GoogleKey)
self.msrsTower:SetProvider(MSRS.Provider.GOOGLE)
end
self.msrsTower:SetCoordinate(self:GetCoordinate()) self.msrsTower:SetCoordinate(self:GetCoordinate())
self:SetSRSTower() self:SetSRSTower()
-- SRS for Pilot. -- SRS for Pilot.
self.msrsPilot=MSRS:New(PathToSRS, Frequency, Modulation) self.msrsPilot=MSRS:New(PathToSRS, Frequency, Modulation)
self.msrsPilot:SetPort(self.Port) self.msrsPilot:SetPort(self.Port)
self.msrsPilot:SetGoogle(GoogleKey) if GoogleKey then
self.msrsPilot:SetProviderOptionsGoogle(GoogleKey,GoogleKey)
self.msrsPilot:SetProvider(MSRS.Provider.GOOGLE)
end
self.msrsTower:SetCoordinate(self:GetCoordinate()) self.msrsTower:SetCoordinate(self:GetCoordinate())
self:SetSRSPilot() self:SetSRSPilot()
@ -633,7 +643,6 @@ function FLIGHTCONTROL:_SetSRSOptions(msrs, Gender, Culture, Voice, Volume, Labe
msrs:SetVoice(Voice) msrs:SetVoice(Voice)
msrs:SetVolume(Volume) msrs:SetVolume(Volume)
msrs:SetLabel(Label) msrs:SetLabel(Label)
msrs:SetGoogle(PathToGoogleCredentials)
msrs:SetCoalition(self:GetCoalition()) msrs:SetCoalition(self:GetCoalition())
msrs:SetPort(Port or self.Port or 5002) msrs:SetPort(Port or self.Port or 5002)
end end
@ -648,12 +657,11 @@ end
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`. See [Google Voices](https://cloud.google.com/text-to-speech/docs/voices). -- @param #string Voice Specific voice. Overrides `Gender` and `Culture`. See [Google Voices](https://cloud.google.com/text-to-speech/docs/voices).
-- @param #number Volume Volume. Default 1.0. -- @param #number Volume Volume. Default 1.0.
-- @param #string Label Name under which SRS transmits. Default `self.alias`. -- @param #string Label Name under which SRS transmits. Default `self.alias`.
-- @param #string PathToGoogleCredentials Path to google credentials json file.
-- @return #FLIGHTCONTROL self -- @return #FLIGHTCONTROL self
function FLIGHTCONTROL:SetSRSTower(Gender, Culture, Voice, Volume, Label, PathToGoogleCredentials) function FLIGHTCONTROL:SetSRSTower(Gender, Culture, Voice, Volume, Label)
if self.msrsTower then if self.msrsTower then
self:_SetSRSOptions(self.msrsTower, Gender or "female", Culture or "en-GB", Voice, Volume, Label or self.alias, PathToGoogleCredentials) self:_SetSRSOptions(self.msrsTower, Gender or "female", Culture or "en-GB", Voice, Volume, Label or self.alias)
end end
return self return self
@ -666,12 +674,11 @@ end
-- @param #string Voice Specific voice. Overrides `Gender` and `Culture`. -- @param #string Voice Specific voice. Overrides `Gender` and `Culture`.
-- @param #number Volume Volume. Default 1.0. -- @param #number Volume Volume. Default 1.0.
-- @param #string Label Name under which SRS transmits. Default "Pilot". -- @param #string Label Name under which SRS transmits. Default "Pilot".
-- @param #string PathToGoogleCredentials Path to google credentials json file.
-- @return #FLIGHTCONTROL self -- @return #FLIGHTCONTROL self
function FLIGHTCONTROL:SetSRSPilot(Gender, Culture, Voice, Volume, Label, PathToGoogleCredentials) function FLIGHTCONTROL:SetSRSPilot(Gender, Culture, Voice, Volume, Label)
if self.msrsPilot then if self.msrsPilot then
self:_SetSRSOptions(self.msrsPilot, Gender or "male", Culture or "en-US", Voice, Volume, Label or "Pilot", PathToGoogleCredentials) self:_SetSRSOptions(self.msrsPilot, Gender or "male", Culture or "en-US", Voice, Volume, Label or "Pilot")
end end
return self return self
@ -876,7 +883,7 @@ end
--- Set ATIS. --- Set ATIS.
-- @param #FLIGHTCONTROL self -- @param #FLIGHTCONTROL self
-- @param Ops.ATIS#ATIS ATIS ATIS. -- @param Ops.ATIS#ATIS Atis ATIS.
-- @return #FLIGHTCONTROL self -- @return #FLIGHTCONTROL self
function FLIGHTCONTROL:SetATIS(Atis) function FLIGHTCONTROL:SetATIS(Atis)
self.atis=Atis self.atis=Atis

View File

@ -2314,14 +2314,17 @@ end
-- @return #OPSGROUP self -- @return #OPSGROUP self
function OPSGROUP:SetSRS(PathToSRS, Gender, Culture, Voice, Port, PathToGoogleKey, Label, Volume) function OPSGROUP:SetSRS(PathToSRS, Gender, Culture, Voice, Port, PathToGoogleKey, Label, Volume)
self.useSRS=true self.useSRS=true
self.msrs=MSRS:New(PathToSRS, self.frequency, self.modulation) local path = PathToSRS or MSRS.path
local port = Port or MSRS.port
self.msrs=MSRS:New(path, self.frequency, self.modulation)
self.msrs:SetGender(Gender) self.msrs:SetGender(Gender)
self.msrs:SetCulture(Culture) self.msrs:SetCulture(Culture)
self.msrs:SetVoice(Voice) self.msrs:SetVoice(Voice)
self.msrs:SetPort(Port) self.msrs:SetPort(port)
self.msrs:SetLabel(Label) self.msrs:SetLabel(Label)
if PathToGoogleKey then if PathToGoogleKey then
self.msrs:SetGoogle(PathToGoogleKey) self.msrs:SetProviderOptionsGoogle(PathToGoogleKey,PathToGoogleKey)
self.msrs:SetProvider(MSRS.Provider.GOOGLE)
end end
self.msrs:SetCoalition(self:GetCoalition()) self.msrs:SetCoalition(self:GetCoalition())
self.msrs:SetVolume(Volume) self.msrs:SetVolume(Volume)

View File

@ -1517,7 +1517,13 @@ function PLAYERRECCE:SetSRS(Frequency,Modulation,PathToSRS,Gender,Culture,Port,V
self.SRS:SetVoice(self.Voice) self.SRS:SetVoice(self.Voice)
self.SRS:SetVolume(self.Volume) self.SRS:SetVolume(self.Volume)
if self.PathToGoogleKey then if self.PathToGoogleKey then
self.SRS:SetGoogle(self.PathToGoogleKey) self.SRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.PathToGoogleKey)
self.SRS:SetProvider(MSRS.Provider.GOOGLE)
end
-- Pre-configured Google?
if (not PathToGoogleKey) and self.AwacsSRS:GetProvider() == MSRS.Provider.GOOGLE then
self.PathToGoogleKey = MSRS.poptions.gcloud.credentials
self.Voice = Voice or MSRS.poptions.gcloud.voice
end end
self.SRSQueue = MSRSQUEUE:New(self.MenuName or self.Name) self.SRSQueue = MSRSQUEUE:New(self.MenuName or self.Name)
self.SRSQueue:SetTransmitOnlyWithPlayers(self.TransmitOnlyWithPlayers) self.SRSQueue:SetTransmitOnlyWithPlayers(self.TransmitOnlyWithPlayers)

View File

@ -4034,9 +4034,10 @@ function PLAYERTASKCONTROLLER:SetSRS(Frequency,Modulation,PathToSRS,Gender,Cultu
if self.PathToGoogleKey then if self.PathToGoogleKey then
--self.SRS:SetGoogle(self.PathToGoogleKey) --self.SRS:SetGoogle(self.PathToGoogleKey)
self.SRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey) self.SRS:SetProviderOptionsGoogle(self.PathToGoogleKey,self.AccessKey)
self.SRS:SetProvider(MSRS.Provider.GOOGLE)
end end
-- Pre-configured Google? -- Pre-configured Google?
if self.SRS:GetProvider() == MSRS.Provider.GOOGLE then if (not PathToGoogleKey) and self.SRS:GetProvider() == MSRS.Provider.GOOGLE then
self.PathToGoogleKey = MSRS.poptions.gcloud.credentials self.PathToGoogleKey = MSRS.poptions.gcloud.credentials
self.Voice = Voice or MSRS.poptions.gcloud.voice self.Voice = Voice or MSRS.poptions.gcloud.voice
self.AccessKey = AccessKey or MSRS.poptions.gcloud.key self.AccessKey = AccessKey or MSRS.poptions.gcloud.key