This python script converts text to speech using the Google Cloud engine. Furthermore, radio effects (high, low pass filters and white noise) can be added to the speech output. The input text is read from an Excel or csv file.
You need to have python and pip installed. Furthermore, the script requires the following packages, which can be easily installed via pip:
- pydub
- google-cloud
- pandas
The input data is provided as a table in either xlsx or csv format:
The xlsx or csv files need to have the following columns:
Text: The text that is converted to speech. This can contain SSML syntax.File Name: The output file name. This will be saved as in.oggformat.Subtitle: An optional subtitle if different from theTextcolumn.Voice Name: The Google voice if other than the default voiceen-US-Standard-A.Highpass: The high pass filter frequency in Hz. Default 4000 Hz.Lowpass: The low pass filter frequency in Hz. Default 3000 Hz.Nfilter: Number of times the high and or low pass filters are applied. Default 3.Volume Boost: The volume boost in dB applied to the final normalized output. Default 0 dB.Noise Boost: The white noise boost in [dB]. DefaultNone. If set, white noise is added. Try a negative value of -25 dB first.Emphasis: Add emphasis to the voice, c.f. https://cloud.google.com/text-to-speech/docs/ssml#emphasis.Rate: Adjust speech rate, c.f. https://cloud.google.com/text-to-speech/docs/ssml#prosodyPitch: Adjust the pitch of the voice, c.f. https://cloud.google.com/text-to-speech/docs/ssml#prosodyClick In: Add a radio click at the beginning of the sound file.Click Out: Add a radio click at the end of the sound file.
Change to the directory, where the ttsr.py file is located and type
python ttsr.py --credentials X:\<Path to JSON file>\google-credentials.json
where the parameter --credentials points to your Google cloud credentials file. Alternatively, you can set the environment variable GOOGLE_APPLICATION_CREDENTIALS to point to the credentials file.
This will scan the current directory for all xlsx and csv files and start the conversion process.
For each input file, a directory named as the input file is created that contains the sound .ogg files.
Additionally, a csv file with the parameters is created that also contains the duration of the sound file as additional column.
This csv file can be used as input for various MOOSE classes (e.g. ATIS, RANGE, AIRBOSS) as described below.
The following command line parameters can be used:
--filetype: Specify whether you want Excelxlsxor comma-separated valuecsvfiles as input.--inputdir: Specify the path of the directory where the input files are located.--inputfile: Specify the path to a single input file (if you do not want to convert all files in a directory).--credentials: Path to your Google credentials file.
Process only csv files in the current directory
python ttsr.py --filetype csv
Process all xlsx and csv files in a certain directory
python ttsr.py --inputdir <Path To Input Files>
Process only one specific input file
python ttsr.py --inputfile <Path to Input File>
Use a specific voice for all input files (overrules setting in input files)
python ttsr.py --voice en-GB-Wavenet-F
Use a white noise for all input files (overrules setting in input files)
python ttsr.py --noise -25
The white noise volume is reduced by -25 dB.
The generated sound files can of course be used in DCS, when included in a mission miz file. Add the generated sound files to your mission (open the miz with 7-zip and drag & drop the folder). The output of the csv files that contain the duration of the sound file can be used in some MOOSE classes.
A simple ATIS script can look like:
local atis=ATIS:New("Batumi", 305)
atis:SetSoundfilesPath("ATIS-en-GB-Wavenet-F/", "Caucasus-en-GB-Wavenet-F/", "NATO Alphabet-en-GB-Wavenet-F/")
atis:SetSoundfilesInfo("D:/DCS/Scripts/My_Missions/parameters-ATIS-en-GB-Wavenet-F.csv")
-- More custom input...
atis:Start()The parameters-ATIS-en-GB-Wavenet-F.csv is the output file generated by the script and needs to be located on your local hard drive (i.e. not in the miz file).
local range=RANGE:New("Test")
range:SetSoundfilesPath("Range/")
range:SetSoundfilesInfo("D:/DCS/Scripts/My_Missions/_Classes/MSRS/parameters-Range.csv")
-- More custom input...
range:Start()WIP, not supported yet.
This script is based on https://github.com/adamclmns/DCS_RadioComm_VoiceLineGenerator
