]> marstr Code Repo - 124thAWS/summary
 
descriptionMaking 124th ATC sound more natural. With Amazon Polly.
last changeThu, 11 Jul 2024 19:27:31 +0000 (21:27 +0200)
shortlog
2024-07-11 MarStrFixed issue of ATC not being recognised correctly;... master
2024-07-10 MarStrInitial commit with script
2024-07-10 MarStrInitial commit with script
2024-07-10 MarStrInitial commit with script
heads
2 months ago master
Description
124thAWS
A Python script allowing to use standard or neural voices of Amazon Polly, in 124thATC. It does so by monitoring 124thATC's output and leveraging Amazon's Polly technology, to generate voice responses that sound more natural.
The voices that 124thATC can use are those that are available on your system, on Windows this set is usually extremely limited. On top of that, they sound very robotic. Not what you'd want when talking to ATC in a flight. While there are solutions available that leverage AI (custom versions of ChatGPT), the costs are - in my opinion - too high. SayIntentions is my prime example. Clocking in at 30 Dollars per month (at the time of this writing), it is deemed not feasible for most.
I did have a look at ChatGPT itself for ATC, and other available tools. I came to the conclusion that 124thATC is one of the best currently available (for offline use).
Through this Python script, you can make 124thATC sound more natural, providing better overall immersion.
Note: this works fine on Windows. Linux and Mac are untested - but I see no reason why it should not work on those two systems. It is Python after all.
Not entirely free!
IMPORTANT: Using this approach may end up not being free. You have a free allowance of 1 million characters per month, no matter which model you choose. But after that, using the service will incur costs. How high the costs are, depends on 1) the amount of ATC calls you make. More calls = more characters. And 2) the selected model. Neural voices are much more natural, but they also require more power to generate - hence the higher costs.
To find out what is best for you, have a look at these pages first:
- Amazon Polly Pricing (Link)
- AWS Polly Cost Calculator (Link)
For example -
If you make 100 ATC calls per day, which have 150 characters on average, you would end up with: 3,000 calls per month, with 450,000 characters in total. Standard Text-to-Speech (monthly): 1.80 USD (again, the standard voice model).
However - I find AWS the best compromise between quality and cost. This is much better than 30 USD per month for SayIntentions.
Preparation
Needless to say, you will need an AWS account. If you do not have one, you will need to get one now. The account itself is free. Go here to create one: (Link)
Then, you will need to provide payment information, in my case it was a credit card. While you will not be charged if you stay within the free allowance, you will be charged if you exceed them. In our case with ATC responses it should, however, not break your bank.
Once this is done you will basically have access to AWS services. You can now log in with your specified email and password as the root user which has access to the AWS console.
Inside the console, go the top right (your name), click on it, and choose Security Credentials.
In the middle you will find the section Access Keys. Click on Create Access Key and **WRITE DOWN** the key and secret somewhere, as it will not be shown again. You will also have the option to download a CSV with the credentials - you can do that too and save it to a safe and private location.
If you want to use AWS and its services elsewhere, you are of course free to install the AWS CLI tools. But for this script, it is not necessary.
Setup
You will need two Python modules: boto3 and pygame. Install them like so:
pip install boto3
pip install pygame
Next, open up the 124thAWS.py script with your favorite editor and make the necessary adjustments as follows:
# -------------------------------------------------------------------
# Enter your access data and your AWS region
# -------------------------------------------------------------------
atc_aws_key = "YOUR_AWS_KEY"
atc_aws_secret = "YOUR_AWS_SECRET"
atc_aws_region = "SERVER REGION"
The first two are self-explanatory. These are the key and secret you have acquired in the previous step.
Most regions have access to Polly - selecting the correct region will accelerate the data transfer of audio data from AWS to your machine. Go to this (Link) and choose your region. For me that is eu-central-1.
If you want the script to show which voice it has selected and what the response is, you can change
atc_show_responses = True
to True. Default is True. Setting this to False disables this display per line spoken.
Next, you need to select your voice model. Default is standard.
atc_aws_voicemodel = 'standard'
Change this to 'neural' if you want to use the more sophisticated voice generation model. Again, keep in mind that this model is more expensive and can incur significantly higher costs should you exceed the free limits.
The next section defines where the text log of X-Plane is located. Typically this sits in the root of your X-Plane installation folder.
atc_xplane_log = "M:\\Flight Sim\\Simulator\\12\\Log.txt"
This is a default example I left in - you need to find the path of your file. This can also be on a network drive - important is that the Python script can access this location. Notice the double backslashes for the folder delimiters.
You will now need to enter your call sign and flight number. In 124thATC when you file a flight plan, you will be asked to provide a callsign and flight number, which has two fields. What you enter here is your call sign.
In my case, I use "MST" as my callsign, and "6012" on the right as my flight number. The resulting callsign will be a string made up of those two with a space. For me this is
MST 6012
This is what you will need to enter at these lines:
atc_callsign = "MST"
atc_flightno = "6012"
Replace this with your own call sign and flight number.
Next, decide whether or not you want a voice for readbacks and/or communication from the cockpit to be played as audio. If you set this to False, only ATC communication will be audible.
atc_captain_voice = True
If you set the previous setting to false, you can skip the paragraph.
If you did set it to true however, you will need to determine which voice your captain shall have. It is a number from the array of Polly voices further down in the script. Count the position of the voice, then subtract 1 from that number. For example if voice number 13 (Geraint) is the one you want, you put in 12 as the number at this variable. This voice will not be used for ATC communications.
atc_pilot_voice = 12
Turn off Windows/TTS voices from 124thATC
Open the Options window, should you have closed it already. There, disable the option "Activate Speech Output" under "Radio" in the bottom left.
Finally: RUNNING
Once you have done all the above steps, open a command prompt and navigate to where the script is located. Then, simply run
python .\124thAWS.py
You will be greeted with a small message, and the script begins to work immediately. Meaning it intercepts ATC messages it will find in the text file. Once an "update" is detected, the voice is generated and played.
The script can be on any machine you want - important is that the script has access to the text file 124thATC generates.
Detailed configuration
You can remove voices from each array you absolutely do not like. In this case, remove them, and adjust your number for the captain voice if you want this enabled.
The script waits 3 seconds before it enters its next processing loop. You can change the number in the last value to something else - however: a lower value performs loops in shorter intervals, but is also more resource-intensive. A higher value is less resource-intensive, but provides slower voice updates.
I find 3 seconds to be a good balance.
The sound format is OGG Vorbis. I would recommend you to leave it at that. It is the best compromise between quality and data transfer size.
Future plans
I may need to figure out how to efficiently read X-Plane's dataref values so that I can further enhance realism. For example only pick another voice if you left a certain area or changed the type of contact. I will be looking into this at some time - for now I am happy with how this has turned out.
History
1.01 - Fixed issue of ATC not being recognised correctly; Introduced callsign and flight number; Fixed issue of numbers not being pronounced correctly
1.0 - Initial release