mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 19:45:29 +00:00
#MSRS
* Added config file loading
This commit is contained in:
@@ -480,21 +480,24 @@ _MESSAGESRS = {}
|
|||||||
-- MESSAGE:New("Test message!",15,"SPAWN"):ToSRS()
|
-- MESSAGE:New("Test message!",15,"SPAWN"):ToSRS()
|
||||||
--
|
--
|
||||||
function MESSAGE.SetMSRS(PathToSRS,Port,PathToCredentials,Frequency,Modulation,Gender,Culture,Voice,Coalition,Volume,Label,Coordinate)
|
function MESSAGE.SetMSRS(PathToSRS,Port,PathToCredentials,Frequency,Modulation,Gender,Culture,Voice,Coalition,Volume,Label,Coordinate)
|
||||||
local path = PathToSRS or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
_MESSAGESRS.MSRS = MSRS:New(PathToSRS,Frequency,Modulation,Volume)
|
||||||
_MESSAGESRS.MSRS = MSRS:New(path,Frequency,Modulation,Volume)
|
|
||||||
_MESSAGESRS.MSRS:SetCoalition(Coalition)
|
_MESSAGESRS.MSRS:SetCoalition(Coalition)
|
||||||
_MESSAGESRS.MSRS:SetCoordinate(Coordinate)
|
_MESSAGESRS.MSRS:SetCoordinate(Coordinate)
|
||||||
_MESSAGESRS.MSRS:SetCulture(Culture)
|
_MESSAGESRS.MSRS:SetCulture(Culture)
|
||||||
_MESSAGESRS.MSRS:SetFrequencies(Frequency)
|
_MESSAGESRS.Culture = Culture
|
||||||
|
--_MESSAGESRS.MSRS:SetFrequencies(Frequency)
|
||||||
_MESSAGESRS.MSRS:SetGender(Gender)
|
_MESSAGESRS.MSRS:SetGender(Gender)
|
||||||
|
_MESSAGESRS.Gender = Gender
|
||||||
_MESSAGESRS.MSRS:SetGoogle(PathToCredentials)
|
_MESSAGESRS.MSRS:SetGoogle(PathToCredentials)
|
||||||
_MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE")
|
_MESSAGESRS.MSRS:SetLabel(Label or "MESSAGE")
|
||||||
_MESSAGESRS.MSRS:SetModulations(Modulation)
|
--_MESSAGESRS.MSRS:SetModulations(Modulation)
|
||||||
_MESSAGESRS.MSRS:SetPath(PathToSRS)
|
--_MESSAGESRS.MSRS:SetPath(PathToSRS)
|
||||||
_MESSAGESRS.MSRS:SetPort(Port)
|
_MESSAGESRS.MSRS:SetPort(Port)
|
||||||
_MESSAGESRS.MSRS:SetVolume(Volume)
|
-- _MESSAGESRS.MSRS:SetVolume(Volume)
|
||||||
_MESSAGESRS.MSRS:SetVoice(Voice)
|
_MESSAGESRS.MSRS:SetVoice(Voice)
|
||||||
|
_MESSAGESRS.Voice = Voice
|
||||||
_MESSAGESRS.SRSQ = MSRSQUEUE:New(Label or "MESSAGE")
|
_MESSAGESRS.SRSQ = MSRSQUEUE:New(Label or "MESSAGE")
|
||||||
|
env.info(_MESSAGESRS.MSRS.provider,false)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Sends a message via SRS.
|
--- Sends a message via SRS.
|
||||||
@@ -517,26 +520,8 @@ end
|
|||||||
--
|
--
|
||||||
function MESSAGE:ToSRS(frequency,modulation,gender,culture,voice,coalition,volume,coordinate)
|
function MESSAGE:ToSRS(frequency,modulation,gender,culture,voice,coalition,volume,coordinate)
|
||||||
if _MESSAGESRS.SRSQ then
|
if _MESSAGESRS.SRSQ then
|
||||||
_MESSAGESRS.MSRS:SetLabel(self.MessageCategory or _MESSAGESRS.MSRS.Label or "MESSAGE")
|
_MESSAGESRS.MSRS:SetVoice(voice or _MESSAGESRS.Voice)
|
||||||
if gender then
|
_MESSAGESRS.SRSQ:NewTransmission(self.MessageText,nil,_MESSAGESRS.MSRS,nil,nil,nil,nil,nil,frequency,modulation,gender or _MESSAGESRS.Gender,culture or _MESSAGESRS.Culture,voice or _MESSAGESRS.Voice,volume,self.MessageCategory)
|
||||||
_MESSAGESRS.MSRS:SetGender(gender)
|
|
||||||
end
|
|
||||||
if coalition then
|
|
||||||
_MESSAGESRS.MSRS:SetCoalition(coalition)
|
|
||||||
end
|
|
||||||
if culture then
|
|
||||||
_MESSAGESRS.MSRS:SetCulture(culture)
|
|
||||||
end
|
|
||||||
if volume then
|
|
||||||
_MESSAGESRS.MSRS:SetVolume(volume)
|
|
||||||
end
|
|
||||||
if coordinate then
|
|
||||||
_MESSAGESRS.MSRS:SetCoordinate(coordinate)
|
|
||||||
end
|
|
||||||
if voice then
|
|
||||||
_MESSAGESRS.MSRS:SetVoice(voice)
|
|
||||||
end
|
|
||||||
_MESSAGESRS.SRSQ:NewTransmission(self.MessageText,nil,_MESSAGESRS.MSRS,nil,1,nil,nil,nil,frequency,modulation)
|
|
||||||
end
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1524,7 +1524,7 @@ end
|
|||||||
-- @param #string GoogleKey Path to Google JSON-Key.
|
-- @param #string GoogleKey Path to Google JSON-Key.
|
||||||
-- @return #ATIS self
|
-- @return #ATIS self
|
||||||
function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port, GoogleKey)
|
function ATIS:SetSRS(PathToSRS, Gender, Culture, Voice, Port, GoogleKey)
|
||||||
if PathToSRS then
|
if PathToSRS or MSRS.path then
|
||||||
self.useSRS=true
|
self.useSRS=true
|
||||||
self.msrs=MSRS:New(PathToSRS, self.frequency, self.modulation)
|
self.msrs=MSRS:New(PathToSRS, self.frequency, self.modulation)
|
||||||
self.msrs:SetGender(Gender)
|
self.msrs:SetGender(Gender)
|
||||||
|
|||||||
@@ -41,12 +41,15 @@
|
|||||||
-- @field #number volume Volume between 0 (min) and 1 (max). Default 1.
|
-- @field #number volume Volume between 0 (min) and 1 (max). Default 1.
|
||||||
-- @field #string culture Culture. Default "en-GB".
|
-- @field #string culture Culture. Default "en-GB".
|
||||||
-- @field #string gender Gender. Default "female".
|
-- @field #string gender Gender. Default "female".
|
||||||
-- @field #string voice Specifc voce.
|
-- @field #string voice Specific voce.
|
||||||
-- @field Core.Point#COORDINATE coordinate Coordinate from where the transmission is send.
|
-- @field Core.Point#COORDINATE coordinate Coordinate from where the transmission is send.
|
||||||
-- @field #string path Path to the SRS exe. This includes the final slash "/".
|
-- @field #string path Path to the SRS exe. This includes the final slash "/".
|
||||||
-- @field #string google Full path google credentials JSON file, e.g. "C:\Users\username\Downloads\service-account-file.json".
|
-- @field #string google Full path google credentials JSON file, e.g. "C:\Users\username\Downloads\service-account-file.json".
|
||||||
-- @field #string Label Label showing up on the SRS radio overlay. Default is "ROBOT". No spaces allowed.
|
-- @field #string Label Label showing up on the SRS radio overlay. Default is "ROBOT". No spaces allowed.
|
||||||
-- @field #table AltBackend Table containing functions and variables to enable an alternate backend to transmit to SRS.
|
-- @field #table AltBackend Table containing functions and variables to enable an alternate backend to transmit to SRS.
|
||||||
|
-- @field #string ConfigFileName Name of the standard config file
|
||||||
|
-- @field #string ConfigFilePath Path to the standard config file
|
||||||
|
-- @field #boolean ConfigLoaded
|
||||||
-- @extends Core.Base#BASE
|
-- @extends Core.Base#BASE
|
||||||
|
|
||||||
--- *It is a very sad thing that nowadays there is so little useless information.* - Oscar Wilde
|
--- *It is a very sad thing that nowadays there is so little useless information.* - Oscar Wilde
|
||||||
@@ -185,11 +188,14 @@ MSRS = {
|
|||||||
coordinate = nil,
|
coordinate = nil,
|
||||||
Label = "ROBOT",
|
Label = "ROBOT",
|
||||||
AltBackend = nil,
|
AltBackend = nil,
|
||||||
|
ConfigFileName = "Moose_MSRS.lua",
|
||||||
|
ConfigFilePath = "Config\\",
|
||||||
|
ConfigLoaded = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
--- MSRS class version.
|
--- MSRS class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
MSRS.version="0.1.3"
|
MSRS.version="0.1.4"
|
||||||
|
|
||||||
--- Voices
|
--- Voices
|
||||||
-- @type MSRS.Voices
|
-- @type MSRS.Voices
|
||||||
@@ -292,6 +298,37 @@ MSRS.Voices = {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
-- @type MSRS.ProviderOptions
|
||||||
|
-- @field #string key
|
||||||
|
-- @field #string secret
|
||||||
|
-- @field #string region
|
||||||
|
-- @field #string defaultVoice
|
||||||
|
-- @field #string voice
|
||||||
|
|
||||||
|
--- GRPC options
|
||||||
|
-- @type MSRS.GRPCOptions
|
||||||
|
-- @field #string plaintext
|
||||||
|
-- @field #string srsClientName
|
||||||
|
-- @field #table position
|
||||||
|
-- @field #string coalition
|
||||||
|
-- @field #MSRS.ProviderOptions gcloud
|
||||||
|
-- @field #MSRS.ProviderOptions win
|
||||||
|
-- @field #MSRS.ProviderOptions azure
|
||||||
|
-- @field #MSRS.ProviderOptions aws
|
||||||
|
-- @field #string DefaultProvider
|
||||||
|
|
||||||
|
MSRS.GRPCOptions = {} -- #MSRS.GRPCOptions
|
||||||
|
MSRS.GRPCOptions.gcloud = {} -- #MSRS.ProviderOptions
|
||||||
|
MSRS.GRPCOptions.win = {} -- #MSRS.ProviderOptions
|
||||||
|
MSRS.GRPCOptions.azure = {} -- #MSRS.ProviderOptions
|
||||||
|
MSRS.GRPCOptions.aws = {} -- #MSRS.ProviderOptions
|
||||||
|
|
||||||
|
MSRS.GRPCOptions.win.defaultVoice = "Hedda"
|
||||||
|
MSRS.GRPCOptions.win.voice = "Hedda"
|
||||||
|
|
||||||
|
MSRS.GRPCOptions.DefaultProvider = "win"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -299,6 +336,8 @@ MSRS.Voices = {
|
|||||||
-- TODO: Add functions to remove freqs and modulations.
|
-- TODO: Add functions to remove freqs and modulations.
|
||||||
-- DONE: Add coordinate.
|
-- DONE: Add coordinate.
|
||||||
-- DONE: Add google.
|
-- DONE: Add google.
|
||||||
|
-- DONE: Add gRPC google options
|
||||||
|
-- DONE: Add loading default config file
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- Constructor
|
-- Constructor
|
||||||
@@ -328,25 +367,49 @@ function MSRS:New(PathToSRS, Frequency, Modulation, Volume, AltBackend)
|
|||||||
|
|
||||||
-- Add parameters to vars so alternate backends can use them if applicable
|
-- Add parameters to vars so alternate backends can use them if applicable
|
||||||
Backend.Vars = Backend.Vars or {}
|
Backend.Vars = Backend.Vars or {}
|
||||||
Backend.Vars.PathToSRS = UTILS.DeepCopy(PathToSRS) -- DeepCopy probably unecessary
|
Backend.Vars.PathToSRS = PathToSRS
|
||||||
Backend.Vars.Frequency = UTILS.DeepCopy(Frequency)
|
Backend.Vars.Frequency = UTILS.DeepCopy(Frequency)
|
||||||
Backend.Vars.Modulation = UTILS.DeepCopy(Modulation)
|
Backend.Vars.Modulation = UTILS.DeepCopy(Modulation)
|
||||||
Backend.Vars.Volume = UTILS.DeepCopy(Volume) -- DeepCopy probably unecessary
|
Backend.Vars.Volume = Volume
|
||||||
|
|
||||||
Backend.Functions = Backend.Functions or {}
|
Backend.Functions = Backend.Functions or {}
|
||||||
|
|
||||||
return self:_NewAltBackend(Backend)
|
return self:_NewAltBackend(Backend)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- If no AltBackend table, the proceed with default initialization
|
local success = self:LoadConfigFile(nil,nil,self.ConfigLoaded)
|
||||||
self:SetPath(PathToSRS)
|
|
||||||
self:SetPort()
|
if (not success) and (not self.ConfigLoaded) then
|
||||||
self:SetFrequencies(Frequency)
|
|
||||||
self:SetModulations(Modulation)
|
-- If no AltBackend table, the proceed with default initialisation
|
||||||
self:SetGender()
|
self:SetPath(PathToSRS)
|
||||||
self:SetCoalition()
|
self:SetPort()
|
||||||
self:SetLabel()
|
self:SetFrequencies(Frequency)
|
||||||
self:SetVolume()
|
self:SetModulations(Modulation)
|
||||||
|
self:SetGender()
|
||||||
|
self:SetCoalition()
|
||||||
|
self:SetLabel()
|
||||||
|
self:SetVolume(Volume)
|
||||||
|
|
||||||
|
else
|
||||||
|
|
||||||
|
-- there might be some overwrites from :New()
|
||||||
|
|
||||||
|
if PathToSRS then
|
||||||
|
self:SetPath(PathToSRS)
|
||||||
|
end
|
||||||
|
|
||||||
|
if Frequency then
|
||||||
|
self:SetFrequencies(Frequency)
|
||||||
|
self:SetModulations(Modulation)
|
||||||
|
end
|
||||||
|
|
||||||
|
if Volume then
|
||||||
|
self:SetVolume(Volume)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
self.lid = string.format("%s-%s | ", self.name, self.version)
|
self.lid = string.format("%s-%s | ", self.name, self.version)
|
||||||
|
|
||||||
if not io or not os then
|
if not io or not os then
|
||||||
@@ -366,24 +429,25 @@ end
|
|||||||
-- @return #MSRS self
|
-- @return #MSRS self
|
||||||
function MSRS:SetPath(Path)
|
function MSRS:SetPath(Path)
|
||||||
|
|
||||||
if Path==nil then
|
if Path==nil and not self.path then
|
||||||
self:E("ERROR: No path to SRS directory specified!")
|
self:E("ERROR: No path to SRS directory specified!")
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set path.
|
if Path then
|
||||||
self.path=Path
|
-- Set path.
|
||||||
|
self.path=Path
|
||||||
|
|
||||||
-- Remove (back)slashes.
|
-- Remove (back)slashes.
|
||||||
local n=1 ; local nmax=1000
|
local n=1 ; local nmax=1000
|
||||||
while (self.path:sub(-1)=="/" or self.path:sub(-1)==[[\]]) and n<=nmax do
|
while (self.path:sub(-1)=="/" or self.path:sub(-1)==[[\]]) and n<=nmax do
|
||||||
self.path=self.path:sub(1,#self.path-1)
|
self.path=self.path:sub(1,#self.path-1)
|
||||||
n=n+1
|
n=n+1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Debug output.
|
||||||
|
self:I(string.format("SRS path=%s", self:GetPath()))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Debug output.
|
|
||||||
self:T(string.format("SRS path=%s", self:GetPath()))
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -579,6 +643,10 @@ function MSRS:SetVoice(Voice)
|
|||||||
|
|
||||||
self.voice=Voice
|
self.voice=Voice
|
||||||
|
|
||||||
|
--local defaultprovider = self.provider or self.GRPCOptions.DefaultProvider or MSRS.GRPCOptions.DefaultProvider or "win"
|
||||||
|
|
||||||
|
--self.GRPCOptions[defaultprovider].voice = Voice
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -589,6 +657,8 @@ end
|
|||||||
function MSRS:SetDefaultVoice(Voice)
|
function MSRS:SetDefaultVoice(Voice)
|
||||||
|
|
||||||
self.defaultVoice=Voice
|
self.defaultVoice=Voice
|
||||||
|
local provider = self.provider or self.GRPCOptions.DefaultProvider or MSRS.GRPCOptions.DefaultProvider or "win"
|
||||||
|
self.GRPCOptions[provider].defaultVoice = Voice
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -606,13 +676,20 @@ end
|
|||||||
|
|
||||||
--- Use google text-to-speech.
|
--- Use google text-to-speech.
|
||||||
-- @param #MSRS self
|
-- @param #MSRS self
|
||||||
-- @param #string PathToCredentials Full path to the google credentials JSON file, e.g. "C:\Users\username\Downloads\service-account-file.json".
|
-- @param #string PathToCredentials Full path to the google credentials JSON file, e.g. "C:\Users\username\Downloads\service-account-file.json". Can also be the Google API key.
|
||||||
-- @return #MSRS self
|
-- @return #MSRS self
|
||||||
function MSRS:SetGoogle(PathToCredentials)
|
function MSRS:SetGoogle(PathToCredentials)
|
||||||
|
|
||||||
self.google=PathToCredentials
|
if PathToCredentials then
|
||||||
self.APIKey=PathToCredentials
|
|
||||||
self.provider = "gcloud"
|
self.google=PathToCredentials
|
||||||
|
self.APIKey=PathToCredentials
|
||||||
|
self.provider = "gcloud"
|
||||||
|
|
||||||
|
self.GRPCOptions.DefaultProvider = "gcloud"
|
||||||
|
self.GRPCOptions.gcloud.key = PathToCredentials
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@@ -622,10 +699,12 @@ end
|
|||||||
-- @param #string APIKey API Key, usually a string of length 40 with characters and numbers.
|
-- @param #string APIKey API Key, usually a string of length 40 with characters and numbers.
|
||||||
-- @return #MSRS self
|
-- @return #MSRS self
|
||||||
function MSRS:SetGoogleAPIKey(APIKey)
|
function MSRS:SetGoogleAPIKey(APIKey)
|
||||||
|
if APIKey then
|
||||||
self.APIKey=APIKey
|
self.APIKey=APIKey
|
||||||
self.provider = "gcloud"
|
self.provider = "gcloud"
|
||||||
|
self.GRPCOptions.DefaultProvider = "gcloud"
|
||||||
|
self.GRPCOptions.gcloud.key = APIKey
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1041,6 +1120,111 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp
|
|||||||
return command
|
return command
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get SRS command to play sound using the `DCS-SR-ExternalAudio.exe`.
|
||||||
|
-- @param #MSRS self
|
||||||
|
-- @param #string Path Path to config file, defaults to "C:\Users\<yourname>\Saved Games\DCS\Config"
|
||||||
|
-- @param #string Filename File to load, defaults to "Moose_MSRS.lua"
|
||||||
|
-- @param #boolean ConfigLoaded - if true, skip the loading
|
||||||
|
-- @return #boolean success
|
||||||
|
function MSRS:LoadConfigFile(Path,Filename,ConfigLoaded)
|
||||||
|
|
||||||
|
local path = Path or lfs.writedir()..MSRS.ConfigFilePath
|
||||||
|
local file = Filename or MSRS.ConfigFileName or "Moose_MSRS.lua"
|
||||||
|
|
||||||
|
if UTILS.CheckFileExists(path,file) and not ConfigLoaded then
|
||||||
|
assert(loadfile(path..file))()
|
||||||
|
-- now we should have a global var MSRS_Config
|
||||||
|
if MSRS_Config then
|
||||||
|
--[[
|
||||||
|
-- Moose MSRS default Config
|
||||||
|
MSRS_Config = {
|
||||||
|
Path = "D:\\Program Files\\DCS-SimpleRadio-Standalone",
|
||||||
|
Port = 5002,
|
||||||
|
Frequency = {127,243}, -- must be a table, 1..n entries!
|
||||||
|
Modulation = {0,0}, -- must be a table, 1..n entries, one for each frequency!
|
||||||
|
Volume = 1.0,
|
||||||
|
Coalition = 0, -- 0 = Neutral, 1 = Red, 2 = Blue
|
||||||
|
Coordinate = {0,0,0}, -- x,y,alt - optional
|
||||||
|
Culture = "en-GB",
|
||||||
|
Gender = "male",
|
||||||
|
Google = "D:\\Program Files\\DCS-SimpleRadio-Standalone\\yourfilename.json", -- path to google json key file - optional
|
||||||
|
Label = "MSRS",
|
||||||
|
Voice = "Microsoft Hazel Desktop",
|
||||||
|
-- gRPC
|
||||||
|
GRPC = { -- see https://github.com/DCS-gRPC/rust-server
|
||||||
|
coalition = "blue", -- blue, red, neutral
|
||||||
|
DefaultProvider = "gcloud", -- win, gcloud, aws, or azure, some of the values below depend on your cloud provider
|
||||||
|
gcloud = {
|
||||||
|
key = "<API Google Key>", -- for gRPC Google API key
|
||||||
|
--secret = "", -- needed for aws
|
||||||
|
--region = "",-- needed for aws
|
||||||
|
defaultVoice = "MSRS.Voices.Google.Standard.en_GB_Standard_F",
|
||||||
|
},
|
||||||
|
win = {
|
||||||
|
defaultVoice = "Microsoft Hazel Desktop",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--]]
|
||||||
|
if self then
|
||||||
|
self.path = MSRS_Config.Path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||||
|
self.port = MSRS_Config.Port or 5002
|
||||||
|
self.frequencies = MSRS_Config.Frequency or {127,243}
|
||||||
|
self.modulations = MSRS_Config.Modulation or {0,0}
|
||||||
|
self.coalition = MSRS_Config.Coalition or 0
|
||||||
|
if MSRS_Config.Coordinate then
|
||||||
|
self.coordinate = COORDINATE:New( MSRS_Config.Coordinate[1],MSRS_Config.Coordinate[2],MSRS_Config.Coordinate[3])
|
||||||
|
end
|
||||||
|
self.culture = MSRS_Config.Culture or "en-GB"
|
||||||
|
self.gender = MSRS_Config.Gender or "male"
|
||||||
|
self.google = MSRS_Config.Google
|
||||||
|
self.Label = MSRS_Config.Label or "MSRS"
|
||||||
|
self.voice = MSRS_Config.Voice or MSRS.Voices.Microsoft.Hazel
|
||||||
|
if MSRS_Config.GRPC then
|
||||||
|
self.provider = MSRS_Config.GRPC.DefaultProvider
|
||||||
|
if MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider] then
|
||||||
|
self.APIKey = MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider].key
|
||||||
|
self.defaultVoice = MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider].defaultVoice
|
||||||
|
self.region = MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider].secret
|
||||||
|
self.secret = MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider].region
|
||||||
|
end
|
||||||
|
end
|
||||||
|
self.ConfigLoaded = true
|
||||||
|
else
|
||||||
|
MSRS.path = MSRS_Config.Path or "C:\\Program Files\\DCS-SimpleRadio-Standalone"
|
||||||
|
MSRS.port = MSRS_Config.Port or 5002
|
||||||
|
MSRS.frequencies = MSRS_Config.Frequency or {127,243}
|
||||||
|
MSRS.modulations = MSRS_Config.Modulation or {0,0}
|
||||||
|
MSRS.coalition = MSRS_Config.Coalition or 0
|
||||||
|
if MSRS_Config.Coordinate then
|
||||||
|
MSRS.coordinate = COORDINATE:New( MSRS_Config.Coordinate[1],MSRS_Config.Coordinate[2],MSRS_Config.Coordinate[3])
|
||||||
|
end
|
||||||
|
MSRS.culture = MSRS_Config.Culture or "en-GB"
|
||||||
|
MSRS.gender = MSRS_Config.Gender or "male"
|
||||||
|
MSRS.google = MSRS_Config.Google
|
||||||
|
MSRS.Label = MSRS_Config.Label or "MSRS"
|
||||||
|
MSRS.voice = MSRS_Config.Voice or MSRS.Voices.Microsoft.Hazel
|
||||||
|
if MSRS_Config.GRPC then
|
||||||
|
MSRS.provider = MSRS_Config.GRPC.DefaultProvider
|
||||||
|
if MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider] then
|
||||||
|
MSRS.APIKey = MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider].key
|
||||||
|
MSRS.defaultVoice = MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider].defaultVoice
|
||||||
|
MSRS.region = MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider].secret
|
||||||
|
MSRS.secret = MSRS_Config.GRPC[MSRS_Config.GRPC.DefaultProvider].region
|
||||||
|
end
|
||||||
|
end
|
||||||
|
MSRS.ConfigLoaded = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
env.info("MSRS - Sucessfully loaded default configuration from disk!",false)
|
||||||
|
else
|
||||||
|
env.info("MSRS - Cannot load default configuration from disk!",false)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- MSRS DCS-gRPC alternate backend
|
-- MSRS DCS-gRPC alternate backend
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
@@ -1303,7 +1487,7 @@ MSRS_BACKEND_DCSGRPC.Functions._DCSgRPCtts = function (self, Text, Plaintext, Fr
|
|||||||
BASE:T("MSRS_BACKEND_DCSGRPC:_DCSgRPCtts()")
|
BASE:T("MSRS_BACKEND_DCSGRPC:_DCSgRPCtts()")
|
||||||
BASE:T({Text, Plaintext, Frequencies, Voice, Label})
|
BASE:T({Text, Plaintext, Frequencies, Voice, Label})
|
||||||
|
|
||||||
local options = {}
|
local options = self.ProviderOptions or MSRS.ProviderOptions or {} -- #MSRS.GRPCOptions
|
||||||
local ssml = Text or ''
|
local ssml = Text or ''
|
||||||
|
|
||||||
local XmitFrequencies = Frequencies or self.Frequency
|
local XmitFrequencies = Frequencies or self.Frequency
|
||||||
@@ -1315,7 +1499,7 @@ MSRS_BACKEND_DCSGRPC.Functions._DCSgRPCtts = function (self, Text, Plaintext, Fr
|
|||||||
options.srsClientName = Label or self.Label
|
options.srsClientName = Label or self.Label
|
||||||
options.position = {}
|
options.position = {}
|
||||||
if self.coordinate then
|
if self.coordinate then
|
||||||
options.position.lat, options.position.lat, options.position.alt = self:_GetLatLongAlt(self.coordinate)
|
options.position.lat, options.position.lon, options.position.alt = self:_GetLatLongAlt(self.coordinate)
|
||||||
end
|
end
|
||||||
|
|
||||||
options.position.lat = options.position.lat or 0.0
|
options.position.lat = options.position.lat or 0.0
|
||||||
@@ -1328,18 +1512,20 @@ MSRS_BACKEND_DCSGRPC.Functions._DCSgRPCtts = function (self, Text, Plaintext, Fr
|
|||||||
options.coalition = 'red'
|
options.coalition = 'red'
|
||||||
end
|
end
|
||||||
|
|
||||||
options[self.provider] = {}
|
local provider = self.provider or self.GRPCOptions.DefaultProvider or MSRS.GRPCOptions.DefaultProvider
|
||||||
|
|
||||||
|
options[provider] = {}
|
||||||
|
|
||||||
if self.APIKey then
|
if self.APIKey then
|
||||||
options[self.provider].key = self.APIKey
|
options[provider].key = self.APIKey
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.defaultVoice then
|
if self.defaultVoice then
|
||||||
options[self.provider].voice = self.defaultVoice
|
--options[provider].defaultVoice = self.defaultVoice
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.voice then
|
if self.voice then
|
||||||
options[self.provider].voice = Voice or self.voice
|
options[provider].voice = Voice or self.voice or self.defaultVoice
|
||||||
elseif ssml then
|
elseif ssml then
|
||||||
-- DCS-gRPC doesn't directly support language/gender, but can use SSML
|
-- DCS-gRPC doesn't directly support language/gender, but can use SSML
|
||||||
-- Only use if a voice isn't explicitly set
|
-- Only use if a voice isn't explicitly set
|
||||||
|
|||||||
@@ -2421,7 +2421,7 @@ function UTILS.CheckFileExists(Path,Filename)
|
|||||||
|
|
||||||
-- Check io module is available.
|
-- Check io module is available.
|
||||||
if not io then
|
if not io then
|
||||||
BASE:E("ERROR: io not desanitized. Can't save current state.")
|
BASE:E("ERROR: io not desanitized.")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user