Merge branch 'FF/MasterDevel' into FF/Ops

This commit is contained in:
Frank 2021-06-01 23:20:59 +02:00
commit 8025862fb9
6 changed files with 102 additions and 35 deletions

View File

@ -21,8 +21,7 @@ _DATABASE:_RegisterZones()
_DATABASE:_RegisterAirbases() _DATABASE:_RegisterAirbases()
--- Check if os etc is available. --- Check if os etc is available.
BASE:I("Checking de-sanitization of os, io and lfs (Check <DCS install folder>/Scripts/MissionScripting.lua and commend out sanitizeModule(''). Use at your own risk!)") BASE:I("Checking de-sanitization of os, io and lfs:")
local __na=false local __na=false
if os then if os then
BASE:I("- os available") BASE:I("- os available")
@ -43,5 +42,5 @@ else
__na=true __na=true
end end
if __na then if __na then
BASE:I("Check <DCS install folder>/Scripts/MissionScripting.lua and commend out the lines with sanitizeModule(''). Use at your own risk!)") BASE:I("Check <DCS install folder>/Scripts/MissionScripting.lua and comment out the lines with sanitizeModule(''). Use at your own risk!)")
end end

View File

@ -18,6 +18,7 @@
-- * Option to present information in imperial or metric units -- * Option to present information in imperial or metric units
-- * Runway length and airfield elevation (optional) -- * Runway length and airfield elevation (optional)
-- * Frequencies/channels of nav aids (ILS, VOR, NDB, TACAN, PRMG, RSBN) (optional) -- * Frequencies/channels of nav aids (ILS, VOR, NDB, TACAN, PRMG, RSBN) (optional)
-- * SRS Simple-Text-To-Speech (STTS) integration (no sound files necessary)
-- --
-- === -- ===
-- --
@ -1115,6 +1116,7 @@ function ATIS:SetSTTS(PathToSRS, Gender, Culture, Voice, Port)
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)
return self return self
end end
@ -2188,9 +2190,6 @@ function ATIS:onafterReport(From, Event, To, Text)
local text=string.gsub(text, ";", ". ") local text=string.gsub(text, ";", ". ")
env.info("FF: "..text) env.info("FF: "..text)
--local msrs=MSRS:New("D:\\DCS\\_SRS\\", 305, Modulation)
--msrs:PlayText(text)
-- Play text-to-speech report. -- Play text-to-speech report.
self.msrs:PlayText(text) self.msrs:PlayText(text)

View File

@ -70,8 +70,8 @@ RADIOQUEUE = {
-- @field #boolean isplaying If true, transmission is currently playing. -- @field #boolean isplaying If true, transmission is currently playing.
-- @field #number Tplay Mission time (abs) in seconds when the transmission should be played. -- @field #number Tplay Mission time (abs) in seconds when the transmission should be played.
-- @field #number interval Interval in seconds before next transmission. -- @field #number interval Interval in seconds before next transmission.
-- @field Sound.SoundFile#SOUNDFILE soundfile Sound file object to play via SRS. -- @field Sound.SoundOutput#SOUNDFILE soundfile Sound file object to play via SRS.
-- @field Sound.SoundFile#SOUNDTEXT soundtext Sound TTS object to play via SRS. -- @field Sound.SoundOutput#SOUNDTEXT soundtext Sound TTS object to play via SRS.
--- Create a new RADIOQUEUE object for a given radio frequency/modulation. --- Create a new RADIOQUEUE object for a given radio frequency/modulation.
@ -176,9 +176,11 @@ end
--- Set SRS. --- Set SRS.
-- @param #RADIOQUEUE self -- @param #RADIOQUEUE self
-- @param #string PathToSRS Path to SRS. -- @param #string PathToSRS Path to SRS.
-- @param #number Port SRS port. Default 5002.
-- @return #RADIOQUEUE self The RADIOQUEUE object. -- @return #RADIOQUEUE self The RADIOQUEUE object.
function RADIOQUEUE:SetSRS(PathToSRS) function RADIOQUEUE:SetSRS(PathToSRS, Port)
self.msrs=MSRS:New(PathToSRS, self.frequency/1000000, self.modulation) self.msrs=MSRS:New(PathToSRS, self.frequency/1000000, self.modulation)
self.msrs:SetPort(Port)
return self return self
end end
@ -284,19 +286,33 @@ function RADIOQUEUE:NewTransmission(filename, duration, path, tstart, interval,
return transmission return transmission
end end
--- Create a new transmission and add it to the radio queue. --- Add a SOUNDFILE to the radio queue.
-- @param #RADIOQUEUE self -- @param #RADIOQUEUE self
-- @param Sound.SoundOutput#SOUNDFILE soundfile Sound file object to be added. -- @param Sound.SoundOutput#SOUNDFILE soundfile Sound file object to be added.
-- @param #number tstart Start time (abs) seconds. Default now. -- @param #number tstart Start time (abs) seconds. Default now.
-- @param #number interval Interval in seconds after the last transmission finished. -- @param #number interval Interval in seconds after the last transmission finished.
-- @return #RADIOQUEUE self -- @return #RADIOQUEUE self
function RADIOQUEUE:AddSoundFile(soundfile, tstart, interval) function RADIOQUEUE:AddSoundFile(soundfile, tstart, interval)
env.info(string.format("FF add soundfile: name=%s%s", soundfile:GetPath(), soundfile:GetFileName())) --env.info(string.format("FF add soundfile: name=%s%s", soundfile:GetPath(), soundfile:GetFileName()))
local transmission=self:NewTransmission(soundfile:GetFileName(), soundfile.duration, soundfile:GetPath(), tstart, interval, soundfile.subtitle, soundfile.subduration) local transmission=self:NewTransmission(soundfile:GetFileName(), soundfile.duration, soundfile:GetPath(), tstart, interval, soundfile.subtitle, soundfile.subduration)
transmission.soundfile=soundfile transmission.soundfile=soundfile
return self return self
end end
--- Add a SOUNDTEXT to the radio queue.
-- @param #RADIOQUEUE self
-- @param Sound.SoundOutput#SOUNDTEXT soundtext Text-to-speech text.
-- @param #number tstart Start time (abs) seconds. Default now.
-- @param #number interval Interval in seconds after the last transmission finished.
-- @return #RADIOQUEUE self
function RADIOQUEUE:AddSoundText(soundtext, tstart, interval)
local transmission=self:NewTransmission("SoundText.ogg", soundtext.duration, nil, tstart, interval, soundtext.subtitle, soundtext.subduration)
transmission.soundtext=soundtext
return self
end
--- Convert a number (as string) into a radio transmission. --- Convert a number (as string) into a radio transmission.
-- E.g. for board number or headings. -- E.g. for board number or headings.
-- @param #RADIOQUEUE self -- @param #RADIOQUEUE self
@ -340,7 +356,7 @@ end
-- @param #RADIOQUEUE.Transmission transmission The transmission. -- @param #RADIOQUEUE.Transmission transmission The transmission.
function RADIOQUEUE:Broadcast(transmission) function RADIOQUEUE:Broadcast(transmission)
if (transmission.soundfile or transmission.soundtext) and self.msrs then if ((transmission.soundfile and transmission.soundfile.useSRS) or transmission.soundtext) and self.msrs then
self:_BroadcastSRS(transmission) self:_BroadcastSRS(transmission)
return return
end end
@ -441,7 +457,7 @@ end
-- @param #RADIOQUEUE.Transmission transmission The transmission. -- @param #RADIOQUEUE.Transmission transmission The transmission.
function RADIOQUEUE:_BroadcastSRS(transmission) function RADIOQUEUE:_BroadcastSRS(transmission)
if transmission.soundfile then if transmission.soundfile and transmission.soundfile.useSRS then
self.msrs:PlaySoundFile(transmission.soundfile) self.msrs:PlaySoundFile(transmission.soundfile)
elseif transmission.soundtext then elseif transmission.soundtext then
self.msrs:PlaySoundText(transmission.soundtext) self.msrs:PlaySoundText(transmission.soundtext)

View File

@ -57,9 +57,40 @@
-- --
-- This class allows to broadcast sound files or text via Simple Radio Standalone (SRS). -- This class allows to broadcast sound files or text via Simple Radio Standalone (SRS).
-- --
-- # Prerequisites -- ## Prerequisites
-- --
-- This script needs SRS version >= 0.9.6. -- This script needs SRS version >= 1.9.6.
--
-- # Play Sound Files
--
-- local soundfile=SOUNDFILE:New("My Soundfile.ogg", "D:\\Sounds For DCS")
-- local msrs=MSRS:New("C:\\Path To SRS", 251, radio.modulation.AM)
-- msrs:PlaySoundFile(soundfile)
--
-- # Play Text-To-Speech
--
-- Basic example:
--
-- -- Create a SOUNDTEXT object.
-- local text=SOUNDTEXT:New("All Enemies destroyed")
--
-- -- MOOSE SRS
-- local msrs=MSRS:New("D:\\DCS\\_SRS\\", 305, radio.modulation.AM)
--
-- -- Text-to speech with default voice after 2 seconds.
-- msrs:PlaySoundText(text, 2)
--
-- ## Set Gender
--
-- Use a specific gender by :SetGender("male") or :SetGender("female").
--
-- ## Set Culture
--
-- Use a specific "culture" by :SetCulture("en-US") or :SetCulture("de-DE").
--
-- ## Set Voice
--
-- Use a specifc voice by :SetVoice("Microsoft Hedda Desktop"). Note that this must be installed on your windows system.
-- --
-- @field #MSRS -- @field #MSRS
MSRS = { MSRS = {
@ -94,6 +125,7 @@ MSRS.version="0.0.3"
-- TODO: Add functions to add/remove freqs and modulations. -- TODO: Add functions to add/remove freqs and modulations.
-- TODO: Add coordinate. -- TODO: Add coordinate.
-- TODO: Add google.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- Constructor -- Constructor
@ -447,14 +479,15 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp
speed=speed or self.speed speed=speed or self.speed
port=port or self.port port=port or self.port
env.info("FF gender="..tostring(gender)) -- Replace modulation
env.info("FF gender="..tostring(self.gender)) modus=modus:gsub("0", "AM")
modus=modus:gsub("1", "FM")
-- This did not work well. Stopped if the transmission was a bit longer with no apparent error. -- This did not work well. Stopped if the transmission was a bit longer with no apparent error.
--local command=string.format("%s --freqs=%s --modulations=%s --coalition=%d --port=%d --volume=%.2f --speed=%d", exe, freqs, modus, coal, port, volume, speed) --local command=string.format("%s --freqs=%s --modulations=%s --coalition=%d --port=%d --volume=%.2f --speed=%d", exe, freqs, modus, coal, port, volume, speed)
-- Command from orig STTS script. Works better for some unknown reason! -- Command from orig STTS script. Works better for some unknown reason!
local command=string.format("start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\"", path, exe, freqs, modus, coal, port, "ROBOT") local command=string.format("start /min \"\" /d \"%s\" /b \"%s\" -f %s -m %s -c %s -p %s -n \"%s\" -h", path, exe, freqs, modus, coal, port, "ROBOT")
-- Set voice or gender/culture. -- Set voice or gender/culture.
if voice then if voice then

View File

@ -57,7 +57,7 @@ do -- Sound File
-- @field #string duration Duration of the sound file in seconds. -- @field #string duration Duration of the sound file in seconds.
-- @field #string subtitle Subtitle of the transmission. -- @field #string subtitle Subtitle of the transmission.
-- @field #number subduration Duration in seconds how long the subtitle is displayed. -- @field #number subduration Duration in seconds how long the subtitle is displayed.
-- @field #boolean insideMiz If true (default), the sound file is located inside the mission .miz file. -- @field #boolean useSRS If true, sound file is played via SRS. Sound file needs to be on local disk not inside the miz file!
-- @extends Core.Base#BASE -- @extends Core.Base#BASE
@ -75,7 +75,7 @@ do -- Sound File
duration = 3, duration = 3,
subtitle = nil, subtitle = nil,
subduration = 0, subduration = 0,
insideMiz = true, useSRS = false,
} }
--- Constructor to create a new SOUNDFILE object. --- Constructor to create a new SOUNDFILE object.
@ -178,6 +178,19 @@ do -- Sound File
return name return name
end end
--- Get the complete sound file name inlcuding its path.
-- @param #SOUNDFILE self
-- @param #boolean Switch If true or nil, use SRS. If false, use DCS transmission.
-- @return #SOUNDFILE self
function SOUNDFILE:UseSRS(Switch)
if Switch==true or Switch==nil then
self.useSRS=true
else
self.useSRS=false
end
return self
end
end end
do -- Text-To-Speech do -- Text-To-Speech
@ -198,15 +211,22 @@ do -- Text-To-Speech
-- --
-- * @{#SOUNDTEXT.New}(*Text, Duration*): Creates a new SOUNDTEXT object. -- * @{#SOUNDTEXT.New}(*Text, Duration*): Creates a new SOUNDTEXT object.
-- --
-- Name: Microsoft Hazel Desktop, Culture: en-GB, Gender: Female, Age: Adult, Desc: Microsoft Hazel Desktop - English (Great Britain) --
-- Name: Microsoft David Desktop, Culture: en-US, Gender: Male, Age: Adult, Desc: Microsoft David Desktop - English (United States) -- # Specific Voice
-- Name: Microsoft Zira Desktop, Culture: en-US, Gender: Female, Age: Adult, Desc: Microsoft Zira Desktop - English (United States) --
-- Name: Microsoft Hedda Desktop, Culture: de-DE, Gender: Female, Age: Adult, Desc: Microsoft Hedda Desktop - German -- You can use a specific voice for the transmission with the @{SOUNDTEXT.SetVoice}(*VoiceName*) function. Here are some examples
-- Name: Microsoft Helena Desktop, Culture: es-ES, Gender: Female, Age: Adult, Desc: Microsoft Helena Desktop - Spanish (Spain) --
-- Name: Microsoft Hortense Desktop, Culture: fr-FR, Gender: Female, Age: Adult, Desc: Microsoft Hortense Desktop - French -- * Name: Microsoft Hazel Desktop, Culture: en-GB, Gender: Female, Age: Adult, Desc: Microsoft Hazel Desktop - English (Great Britain)
-- Name: Microsoft Elsa Desktop, Culture: it-IT, Gender: Female, Age: Adult, Desc: Microsoft Elsa Desktop - Italian (Italy) -- * Name: Microsoft David Desktop, Culture: en-US, Gender: Male, Age: Adult, Desc: Microsoft David Desktop - English (United States)
-- Name: Microsoft Irina Desktop, Culture: ru-RU, Gender: Female, Age: Adult, Desc: Microsoft Irina Desktop - Russian -- * Name: Microsoft Zira Desktop, Culture: en-US, Gender: Female, Age: Adult, Desc: Microsoft Zira Desktop - English (United States)
-- Name: Microsoft Huihui Desktop, Culture: zh-CN, Gender: Female, Age: Adult, Desc: Microsoft Huihui Desktop - Chinese (Simplified) -- * Name: Microsoft Hedda Desktop, Culture: de-DE, Gender: Female, Age: Adult, Desc: Microsoft Hedda Desktop - German
-- * Name: Microsoft Helena Desktop, Culture: es-ES, Gender: Female, Age: Adult, Desc: Microsoft Helena Desktop - Spanish (Spain)
-- * Name: Microsoft Hortense Desktop, Culture: fr-FR, Gender: Female, Age: Adult, Desc: Microsoft Hortense Desktop - French
-- * Name: Microsoft Elsa Desktop, Culture: it-IT, Gender: Female, Age: Adult, Desc: Microsoft Elsa Desktop - Italian (Italy)
-- * Name: Microsoft Irina Desktop, Culture: ru-RU, Gender: Female, Age: Adult, Desc: Microsoft Irina Desktop - Russian
-- * Name: Microsoft Huihui Desktop, Culture: zh-CN, Gender: Female, Age: Adult, Desc: Microsoft Huihui Desktop - Chinese (Simplified)
--
-- Note that this must be installed on your windos machine. Also note that this overrides any culture and gender settings.
-- --
-- @field #SOUNDTEXT -- @field #SOUNDTEXT
SOUNDTEXT={ SOUNDTEXT={
@ -224,7 +244,7 @@ do -- Text-To-Speech
local self=BASE:Inherit(self, BASE:New()) -- #SOUNDTEXT local self=BASE:Inherit(self, BASE:New()) -- #SOUNDTEXT
self:SetText(Text) self:SetText(Text)
self:SetDuration(Duration) self:SetDuration(Duration or STTS.getSpeechTime(Text))
--self:SetGender() --self:SetGender()
--self:SetCulture() --self:SetCulture()
@ -270,11 +290,11 @@ do -- Text-To-Speech
--- Set to use a specific voice name. --- Set to use a specific voice name.
-- See the list from `DCS-SR-ExternalAudio.exe --help` or if using google see https://cloud.google.com/text-to-speech/docs/voices -- See the list from `DCS-SR-ExternalAudio.exe --help` or if using google see https://cloud.google.com/text-to-speech/docs/voices
-- @param #SOUNDTEXT self -- @param #SOUNDTEXT self
-- @param #string Voice Voice name. Note that this will overrule `Gender` and `Culture`. -- @param #string VoiceName Voice name. Note that this will overrule `Gender` and `Culture`.
-- @return #SOUNDTEXT self -- @return #SOUNDTEXT self
function SOUNDTEXT:SetVoice(Voice) function SOUNDTEXT:SetVoice(VoiceName)
self.voice=Voice self.voice=VoiceName
return self return self
end end

View File

@ -1,4 +1,4 @@
--- **Core** - Manage user sound. --- **Sound** - Manage user sound.
-- --
-- === -- ===
-- --
@ -16,7 +16,7 @@
-- --
-- === -- ===
-- --
-- @module Core.UserSound -- @module Sound.UserSound
-- @image Core_Usersound.JPG -- @image Core_Usersound.JPG
do -- UserSound do -- UserSound