From cfcd7d7588bf4d4cbb6aecc13e2c1e6e13a7bd76 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 30 May 2021 22:36:52 +0200 Subject: [PATCH 1/3] Sound update --- Moose Development/Moose/Globals.lua | 5 ++-- Moose Development/Moose/Ops/ATIS.lua | 4 +-- Moose Development/Moose/Sound/RadioQueue.lua | 30 ++++++++++++++----- Moose Development/Moose/Sound/SRS.lua | 5 +--- Moose Development/Moose/Sound/SoundOutput.lua | 19 ++++++++++-- Moose Development/Moose/Sound/UserSound.lua | 4 +-- 6 files changed, 45 insertions(+), 22 deletions(-) diff --git a/Moose Development/Moose/Globals.lua b/Moose Development/Moose/Globals.lua index fdc6db2c7..734f7c1df 100644 --- a/Moose Development/Moose/Globals.lua +++ b/Moose Development/Moose/Globals.lua @@ -20,8 +20,7 @@ _DATABASE:_RegisterCargos() _DATABASE:_RegisterZones() --- Check if os etc is available. -BASE:I("Checking de-sanitization of os, io and lfs (Check /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 if os then BASE:I("- os available") @@ -42,5 +41,5 @@ else __na=true end if __na then - BASE:I("Check /Scripts/MissionScripting.lua and commend out the lines with sanitizeModule(''). Use at your own risk!)") + BASE:I("Check /Scripts/MissionScripting.lua and comment out the lines with sanitizeModule(''). Use at your own risk!)") end \ No newline at end of file diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index 3870ba197..c278539fc 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -1115,6 +1115,7 @@ function ATIS:SetSTTS(PathToSRS, Gender, Culture, Voice, Port) self.msrs:SetGender(Gender) self.msrs:SetCulture(Culture) self.msrs:SetVoice(Voice) + self.msrs:SetPort(Port) return self end @@ -2187,9 +2188,6 @@ function ATIS:onafterReport(From, Event, To, Text) -- Replace ";" by "." local text=string.gsub(text, ";", ". ") env.info("FF: "..text) - - --local msrs=MSRS:New("D:\\DCS\\_SRS\\", 305, Modulation) - --msrs:PlayText(text) -- Play text-to-speech report. self.msrs:PlayText(text) diff --git a/Moose Development/Moose/Sound/RadioQueue.lua b/Moose Development/Moose/Sound/RadioQueue.lua index 53207850f..11cea9de8 100644 --- a/Moose Development/Moose/Sound/RadioQueue.lua +++ b/Moose Development/Moose/Sound/RadioQueue.lua @@ -70,8 +70,8 @@ RADIOQUEUE = { -- @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 interval Interval in seconds before next transmission. --- @field Sound.SoundFile#SOUNDFILE soundfile Sound file object to play via SRS. --- @field Sound.SoundFile#SOUNDTEXT soundtext Sound TTS object to play via SRS. +-- @field Sound.SoundOutput#SOUNDFILE soundfile Sound file 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. @@ -176,9 +176,11 @@ end --- Set SRS. -- @param #RADIOQUEUE self -- @param #string PathToSRS Path to SRS. +-- @param #number Port SRS port. Default 5002. -- @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:SetPort(Port) return self end @@ -284,19 +286,33 @@ function RADIOQUEUE:NewTransmission(filename, duration, path, tstart, interval, return transmission end ---- Create a new transmission and add it to the radio queue. +--- Add a SOUNDFILE to the radio queue. -- @param #RADIOQUEUE self -- @param Sound.SoundOutput#SOUNDFILE soundfile Sound file object to be added. -- @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: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) transmission.soundfile=soundfile return self 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. -- E.g. for board number or headings. -- @param #RADIOQUEUE self @@ -340,7 +356,7 @@ end -- @param #RADIOQUEUE.Transmission transmission The 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) return end @@ -441,7 +457,7 @@ end -- @param #RADIOQUEUE.Transmission transmission The transmission. function RADIOQUEUE:_BroadcastSRS(transmission) - if transmission.soundfile then + if transmission.soundfile and transmission.soundfile.useSRS then self.msrs:PlaySoundFile(transmission.soundfile) elseif transmission.soundtext then self.msrs:PlaySoundText(transmission.soundtext) diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index 78cbaeaf2..119f9b167 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -447,14 +447,11 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp speed=speed or self.speed port=port or self.port - env.info("FF gender="..tostring(gender)) - env.info("FF gender="..tostring(self.gender)) - -- 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) -- 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. if voice then diff --git a/Moose Development/Moose/Sound/SoundOutput.lua b/Moose Development/Moose/Sound/SoundOutput.lua index 697d63941..bb974af08 100644 --- a/Moose Development/Moose/Sound/SoundOutput.lua +++ b/Moose Development/Moose/Sound/SoundOutput.lua @@ -57,7 +57,7 @@ do -- Sound File -- @field #string duration Duration of the sound file in seconds. -- @field #string subtitle Subtitle of the transmission. -- @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 @@ -75,7 +75,7 @@ do -- Sound File duration = 3, subtitle = nil, subduration = 0, - insideMiz = true, + useSRS = false, } --- Constructor to create a new SOUNDFILE object. @@ -178,6 +178,19 @@ do -- Sound File return name 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 do -- Text-To-Speech @@ -224,7 +237,7 @@ do -- Text-To-Speech local self=BASE:Inherit(self, BASE:New()) -- #SOUNDTEXT self:SetText(Text) - self:SetDuration(Duration) + self:SetDuration(Duration or STTS.getSpeechTime(Text)) --self:SetGender() --self:SetCulture() diff --git a/Moose Development/Moose/Sound/UserSound.lua b/Moose Development/Moose/Sound/UserSound.lua index b0f6fb393..8b94ad114 100644 --- a/Moose Development/Moose/Sound/UserSound.lua +++ b/Moose Development/Moose/Sound/UserSound.lua @@ -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 do -- UserSound From 05f95796f6abec34c23f61c652d977fa0ef94c67 Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 31 May 2021 23:47:43 +0200 Subject: [PATCH 2/3] Sound update --- Moose Development/Moose/Ops/ATIS.lua | 1 + Moose Development/Moose/Sound/SRS.lua | 36 +++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Ops/ATIS.lua b/Moose Development/Moose/Ops/ATIS.lua index c278539fc..8f6d3045b 100644 --- a/Moose Development/Moose/Ops/ATIS.lua +++ b/Moose Development/Moose/Ops/ATIS.lua @@ -18,6 +18,7 @@ -- * Option to present information in imperial or metric units -- * Runway length and airfield elevation (optional) -- * Frequencies/channels of nav aids (ILS, VOR, NDB, TACAN, PRMG, RSBN) (optional) +-- * SRS Simple-Text-To-Speech (STTS) integration (no sound files necessary) -- -- === -- diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index 119f9b167..04eaa762d 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -57,9 +57,40 @@ -- -- 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 :SetGender("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 MSRS = { @@ -94,6 +125,7 @@ MSRS.version="0.0.3" -- TODO: Add functions to add/remove freqs and modulations. -- TODO: Add coordinate. +-- TODO: Add google. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -- Constructor From bb43b08190a3d63bbe1f8720e0b6399f3929b2d0 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 1 Jun 2021 23:20:38 +0200 Subject: [PATCH 3/3] Sound update --- Moose Development/Moose/Sound/SRS.lua | 6 +++- Moose Development/Moose/Sound/SoundOutput.lua | 31 ++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/Moose Development/Moose/Sound/SRS.lua b/Moose Development/Moose/Sound/SRS.lua index 04eaa762d..40732802f 100644 --- a/Moose Development/Moose/Sound/SRS.lua +++ b/Moose Development/Moose/Sound/SRS.lua @@ -86,7 +86,7 @@ -- -- ## Set Culture -- --- Use a specific "culture" by :SetCulture("en-US") or :SetGender("de-DE"). +-- Use a specific "culture" by :SetCulture("en-US") or :SetCulture("de-DE"). -- -- ## Set Voice -- @@ -479,6 +479,10 @@ function MSRS:_GetCommand(freqs, modus, coal, gender, voice, culture, volume, sp speed=speed or self.speed port=port or self.port + -- Replace modulation + 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. --local command=string.format("%s --freqs=%s --modulations=%s --coalition=%d --port=%d --volume=%.2f --speed=%d", exe, freqs, modus, coal, port, volume, speed) diff --git a/Moose Development/Moose/Sound/SoundOutput.lua b/Moose Development/Moose/Sound/SoundOutput.lua index bb974af08..bbe93cfa6 100644 --- a/Moose Development/Moose/Sound/SoundOutput.lua +++ b/Moose Development/Moose/Sound/SoundOutput.lua @@ -211,15 +211,22 @@ do -- Text-To-Speech -- -- * @{#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) - -- 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 - -- 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) + -- + -- # Specific Voice + -- + -- You can use a specific voice for the transmission with the @{SOUNDTEXT.SetVoice}(*VoiceName*) function. Here are some examples + -- + -- * 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) + -- * 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 + -- * 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 SOUNDTEXT={ @@ -283,11 +290,11 @@ do -- Text-To-Speech --- 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 -- @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 - function SOUNDTEXT:SetVoice(Voice) + function SOUNDTEXT:SetVoice(VoiceName) - self.voice=Voice + self.voice=VoiceName return self end