Guide / Tutorial TARGET SCRIPTING TUTORIAL: Using Text-To-Speech feedback without Voice Attack

UPDATED: to include a volume override and ability to use different voices on the fly.

CLARIFICATION: This is NOT a speech recognition engine. This is a text to speech engine you can use to issue voice feedback due to control inputs from your HOTAS or simple game events included within the context of the status.json journal file.

Hi people,

Another tutorial to hopefully add a layer of immersion to the game via a TARGET Script Text to Speech function.
This tutorial uses a command line applet called 'voice.exe' which can be downloaded from
The site includes the source code so you can be assured it doesn't contain any viruses.

Of course, you can use Voice Attack to play text-to-speech messages, however, I've found this method to be much easier and it costs nothing.

First up, download 'voice.exe' and copy it to a folder on your PC.
For the purposes of this tutorial, I created a folder called 'Thrustmaster\ED_TargetScript' on my C:\ drive and copied 'voice.exe' there.
I would suggest you run voice.exe from the command line within the folder you copied it to to ensure it's working.
(I believe it requires Windows Speech Engine to be configured and running...which it is by far as I know)

Running voice.exe from the command line with no command line arguments returns a list of options you can use.

You must set the alias for 'VoicePath' correctly to where ever you copied it to within the code.
Optionally you can set 'VoiceCMD' as a string for any command line arguments you wish to include.

Here's my fully commented code...(again, probably more comments than code!)

// Text To Speech //

// Uses voice.exe which can be downloaded from

// Refer fnTextToSpeech(text) function for usage etc
// Set voicepath to where you copied voice.exe. Add any command line arguments you want within 'VoiceCMD'!
// Run voice.exe in a command prompt (from where you copied it) with no arguments etc to see a list of options
// VoiceCMD is example on how to use command line arguments. Rate = 2

alias    VoicePath            = "c:\\Thrustmaster\\ED_TargetScript\\voice.exe";     // NOTE: the double backslashes
alias    VoiceCMD            = "-r 2";     // Speaks the text slightly faster than "normal"

// Add or remove voices available on your PC. Run 'voice.exe -l" (lower case L) in a command line where you copied voice.exe to, to see which voices are installed.
// The below are the voices I've installed and tested on my PC...add or remove any you want to use

alias   Hazel                = "-n \"Microsoft Hazel Desktop\"";        // Adult, Female,    en-GB
alias   Susan                = "-n \"Microsoft Susan\"";                // Adult, Female,    en-GB
alias   George                = "-n \"Microsoft George\"";            // Adult, Male,        en-GB
alias   James                = "-n \"Microsoft James\"";                // Adult, Male,        en-AU
alias   Catherine            = "-n \"Microsoft Catherine\"";            // Adult, Female,    en-AU
alias   Sean                = "-n \"Microsoft Sean\"";                // Adult, Male,        en-IE
alias   Richard                = "-n \"Microsoft Richard\"";            // Adult, Male,        en-CA
alias   Linda                = "-n \"Microsoft Linda\"";                // Adult, Female,    en-CA
alias   David                = "-n \"Microsoft David Desktop\"";        // Adult, Male,        en-US
alias   Mark                = "-n \"Microsoft Mark Desktop\"";        // Adult, Male,        en-US
alias   Zira                = "-n \"Microsoft Zira Desktop\"";        // Adult, Female,    en-US
alias   Heera                = "-n \"Microsoft Heera\"";                // Adult, Male,        en-IN
alias   Ravi                = "-n \"Microsoft Ravi\"";                // Adult, Female,    en-IN

int      DefaultVoice        = &Catherine;            // Set your preferred (installed) voice here
int      VoiceVolume       = 75;                          // Set your default volume

// FUNCTION:     Text to Speech using voice.exe
// Parameter:    Text string to convert to speech,
//                Optional 'VolumeOverride' to override current volume setting
//                Optional 'Voice' to use. 'Voice' parameter must match a currently installed MS Voice

// Usage1:        fnTextToSpeech("This is test number 1");    // says the text at current value of 'VoiceVolume' in %

// Usage2:        int VoiceTxt = "This is test number 2";
//                fnTextToSpeech(VoiceTxt, 100);                // says the text at 100% volume

// Usage3:        char VoiceTxt; Dim(&VoiceTxt, 16); VoiceTxt[0] = 0;
//                int tString = "This is test ";
//                int test = 3;
//                sprintf(&VoiceTxt, "%s number %d", tString, test);
//                fnTextToSpeech(&VoiceTxt, 50);                //says the text at 50% volume

// Usage4:        fnTextToSpeech("Test number 4", 0, &David);    //says the text at default volume using "David" voice ("David" voice must be installed on your PC for this to work)

int fnTextToSpeech(int text, int VolumeOverride=0, int Voice=DefaultVoice) {
char volume; Dim (&volume, 4); volume[0] = 0;
char SysCmd; Dim(&SysCmd, 255); SysCmd[0] = 0;            // Increase buffersize if required

if (VolumeOverride > 0) {
       sprintf(&volume, "%d", VolumeOverride);
else {
       sprintf(&volume, "%d", VoiceVolume);
volume[3] = 0;                        // terminate char array
sprintf(&SysCmd, "start %s -v %s %s %s %s", &VoicePath, &volume, &VoiceCMD, Voice, text);
SysCmd[strlen(&SysCmd)] = 0;                            // terminate char array with nul
system(&SysCmd);                                        // send command to Windows

The system() call uses 'start' which will play the text-to-speech in parallel to your script thereby not causing any delays.
The biggest issue I have run into so far is if I call the function multiple times, too close together, you may get overlaps in the playback.
When I've encountered this in my scripts, I simply use a DeferCall() to delay the playback.

The example I have used in the code above, uses a 'rate' argument, which speeds up the playback.

If you fancy a non-default voice, try running 'voice --list' from the command line.
This will display a list of all the voices available on your PC.
Additional voices are available from Microsoft and can be downloaded and installed for free.

To use the fnTextToSpeech() function in your TARGET Script, simply call the function and parse it the text you want it to say.
You may also optionally parse a volume override and a different voice if you have more than one installed on your PC.
(see code and ensure the voices you wish to use are listed as aliases)

For this example I use an int variable called VoiceTxt containing a string, in my calling code.


int VoiceTxt = "Greetings commander";

I'm happy to help anyone if you run into issues.
Simply reply in this thread, or send me a PM.

Have fun.


CREDITS: Eli Fulkerson for the voice.exe command line text to speech utility.
Last edited:
UPDATED: to include a volume override and ability to use different voices on the fly.

To add voices to Win10 see the following;

And to make them visible to voice.exe, you need to tweak the registry using the method described here;

It is a bit fiddly, but relatively easy.
I created a registry scrap for each voice I have installed so if I ever need to re-install windows etc, the process will be much easier.

Last edited:
Top Bottom