Module Utilities.STTS
Utilities - DCS Simple Text-To-Speech (STTS).
Global(s)
Global STTS |
Simple Text-To-Speech Version 0.4 - Compatible with SRS version 1.9.6.0+ DCS Modification RequiredYou will need to edit MissionScripting.lua in DCS World/Scripts/MissionScripting.lua and remove the sanitization. |
Simple Text-To-Speech
Version 0.4 - Compatible with SRS version 1.9.6.0+
DCS Modification Required
You will need to edit MissionScripting.lua in DCS World/Scripts/MissionScripting.lua and remove the sanitization.
To do this remove all the code below the comment - the line starts "local function sanitizeModule(name)" Do this without DCS running to allow mission scripts to use os functions.
You WILL HAVE TO REAPPLY AFTER EVERY DCS UPDATE
USAGE:
Add this script into the mission as a DO SCRIPT or DO SCRIPT FROM FILE to initialize it Make sure to edit the STTS.SRS_PORT and STTS.DIRECTORY to the correct values before adding to the mission. Then its as simple as calling the correct function in LUA as a DO SCRIPT or in your own scripts.
Example calls:
STTS.TextToSpeech("Hello DCS WORLD","251","AM","1.0","SRS",2)
Arguments in order are:
- Message to say, make sure not to use a newline (\n) !
- Frequency in MHz
- Modulation - AM/FM
- Volume - 1.0 max, 0.5 half
- Name of the transmitter - ATC, RockFM etc
- Coalition - 0 spectator, 1 red 2 blue
- OPTIONAL - Vec3 Point i.e Unit.getByName("A UNIT"):getPoint() - needs Vec3 for Height! OR null if not needed
- OPTIONAL - Speed -10 to +10
- OPTIONAL - Gender male, female or neuter
- OPTIONAL - Culture - en-US, en-GB etc
- OPTIONAL - Voice - a specific voice by name. Run DCS-SR-ExternalAudio.exe with --help to get the ones you can use on the command line
- OPTIONAL - Google TTS - Switch to Google Text To Speech - Requires STTS.GOOGLE_CREDENTIALS path and Google project setup correctly
Example
This example will say the words "Hello DCS WORLD" on 251 MHz AM at maximum volume with a client called SRS and to the Blue coalition only
STTS.TextToSpeech("Hello DCS WORLD","251","AM","1.0","SRS",2,null,-5,"male","en-GB")
Example
This example will say the words "Hello DCS WORLD" on 251 MHz AM at maximum volume with a client called SRS and to the Blue coalition only centered on the position of the Unit called "A UNIT"
STTS.TextToSpeech("Hello DCS WORLD","251","AM","1.0","SRS",2,Unit.getByName("A UNIT"):getPoint(),-5,"male","en-GB")
Arguments in order are:
- FULL path to the MP3 OR OGG to play
- Frequency in MHz - to use multiple separate with a comma - Number of frequencies MUST match number of Modulations
- Modulation - AM/FM - to use multiple
- Volume - 1.0 max, 0.5 half
- Name of the transmitter - ATC, RockFM etc
- Coalition - 0 spectator, 1 red 2 blue
Example
This will play that MP3 on 255MHz AM & 31 FM at half volume with a client called "Multiple" and to Spectators only
STTS.PlayMP3("C:\\Users\\Ciaran\\Downloads\\PR-Music.mp3","255,31","AM,FM","0.5","Multiple",0)
Type(s)
Fields and Methods inherited from STTS | Description |
---|---|
Path of the SRS directory. |
|
DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING |
|
Google credentials file |
|
STTS.PlayMP3(pathToMP3, freqs, modulations, volume, name, coalition, point) |
Play mp3 function. |
LOCAL SRS PORT - DEFAULT IS 5002 |
|
Text to speech function. |
|
Function returns estimated speech time in seconds. |
|
Round a number. |
|
Function for UUID. |
Field(s)
Path of the SRS directory.
DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING
Google credentials file
LOCAL SRS PORT - DEFAULT IS 5002
Function(s)
Play mp3 function.
Defined in:
STTS
Parameters:
#string pathToMP3
Path to the sound file.
#string freqs
Frequencies, e.g. "305, 256".
#string modulations
Modulations, e.g. "AM, FM".
#string volume
Volume, e.g. "0.5".
name
coalition
point
Text to speech function.
Defined in:
STTS
Parameters:
message
freqs
modulations
volume
name
coalition
point
speed
gender
culture
voice
googleTTS
Function returns estimated speech time in seconds.
Assumptions for time calc: 100 Words per min, average of 5 letters for english word so
- 5 chars * 100wpm = 500 characters per min = 8.3 chars per second
So length of msg / 8.3 = number of seconds needed to read it. rounded down to 8 chars per sec map function:
- (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min
Defined in:
STTS
Parameters:
#number length
can also be passed as #string
#number speed
Defaults to 1.0
#boolean isGoogle
We're using Google TTS
Round a number.
Defined in:
STTS
Parameters:
#number x
Number.
#number n
Precision.