TSW Python Announcements Program

This is my A-Level Computer Science project, which is due in Feb 2024. Any feedback on it before that date would be much appreciated.
This is a Major update to the program. It now uses Tkinter interfaces and databases to run announcements, instead of the command line.

Well, well, well. I have an update for you at last. Sorry for the delay since May! I have been extremly busy with school work in my final year of A-Levels. This is my computer science project for my component 3. Any feedback would be greatly appreciated. I have really enjoyed coding this version, so I hope you like it too!

This python program adds extra realism to your Train Sim games. You can now have station by station announcements, just like you hear on real trains, with the ability to create custom routes between stations to fit whatever route you choose to play in the game.

For further information, please read the 'README.txt' attached in the downloadable file.

ChangeLog

  • Whole new program built from the ground up, using a tkinter interface, instead of command line
  • For a full changelog, look in the README.txt file, located in the main folder.

Requirements

Overview — mutagen

**External python module required. Installation instructions in 'README.txt'. **

Used to get length of MP3 file to not overlap the files.

PyAudio
PyAudio
PyPI

**External python module required. Installation instructions in 'README.txt'. **

Used to play all MP3 files when announcing.

www.pygame.org

**External python module required. Installation instructions in 'README.txt'. **

Used for an upcoming feature of a microphone passthrough.

Installation Instructions

-- Instalation for Windows
Make sure that 'Add Python to PATH' was ticked when IDLE was installed, or the modules won't work correctly.
If nessecary, reinstall Python IDLE and tick this option.
Do not install IDLE from the Windows Store.

-Required Modules
	- pygame
	- mutagen
	- pyaudio

-Download and unzip the folder. (NOTE: If you don't unzip it, it won't work.)

- Open command prompt.
- Install required modules listed above: 
	- 'python -m pip install MODULE_NAME_GOES_HERE'
- Open Train Sim Announcer.py, by double clicking, or opening in IDLE
- (IDLE) - Press F5 to run the program. 

-- Instalation for Linux

-Required Modules
		- pygame
		- mutagen
		- pyaudio
		
- Open command prompt.
- Install all required modules
	- 'sudo apt-get install python3-MODULE_NAME_GOES_HERE'
- Open Train Sim Announcer.py
- Run the program

- The program is not being maintained on Linux. If you notice a problem with running the program on Linux, please don't hesitate to contact me. 

Additional Comments

If you would like to donate, you can do so here:
https://www.buymeacoffee.com/LiamS494
Thank you for your support.

Tags: announcements bakerloo-line birmingham great-western-express isle-of-wight london-commuter northern-trans-pennine python southeastern-high-speed west-cornwall-local

Files

Train Sim Announcer - v3.0.zip 2 MB · Added 17 Jan 2024 · Downloaded 245×

Previously uploaded files have been downloaded 1,862 times before being withdrawn.

Comments

Avatar of KCRCRailway
KCRCRailway 24 Sept 2022

Hello!
Your programme is extremely useful, especially that we can easily sub the audio file with real world one simply by renaming the file (hope you don't mind!), I got some questions though, you can find me at the TSC Discord (https://discord.com/invite/G6MZ5SR4TR) which will be really useful for both you as author and us the users since it will be easier to exchange ideas.
1: Will you plan to add off-world destinations? Currently on the GWE one the programme does not provide stations outside such as Greenford and Bristol. While digging files I discover that you added some station that was not in game, so I assume you might update the list in future to include these stations as well.
2: Will there be legal issues to publish your mod with real world PA? Since all PA are manually recorded (assuming it's you who did them), I wonder if it was allowed to publish update that use real world PA (https://rail-announcements.davwheat.dev/). I have a feeling that it will be a bit problematic if you didn't contact both the website and the actual owner of the PA. But I believe at least for 61016 theres official recording that was somewhere on internet published as required from free info (https://www.whatdotheyknow.com/request/see_something_say_something_sort_2#incoming-939458)
I hope these questions helps you and wishing to see you in the Discord.

Avatar of davwheat
davwheat 19 Dec 2022

It's always fun to see myself referenced in the wild! 😄

All the raw audio files are in the GitHub source, if anyone is curious: https://github.com/davwheat/rail-announcements/tree/main/static/audio

Avatar of KCRCRailway
KCRCRailway 20 Dec 2022

Not sure if reply work, hope you see this Davwheat:P
Guess at least I can DIY myself while hoping you and Liam reach cooperation on this :) I just informed Liam that you are here on TSC's Discord, you might able to contact with Liam directly there (though probably will got a few day's delay as Liam seems busy)

Avatar of KCRCRailway
KCRCRailway 25 Sept 2022

Also, I just discover that on SE list, Greenhith was missed---This got fixed by adding 20. Greenhith in list. This might means we can add those off map destination ourselves? Does this also mean we just need to create another list in case we wish to use route outside GWW/BKL/SEHX?

Avatar of Liam-S-494
Liam-S-494 25 Sept 2022

Hi there, thanks for the comment!

Sorry the thing about Greenhithe not showing up was a bug in the 'se_stations.txt'. I've fixed it now and will deploy it soon. Thanks for letting me know!

With reference to adding 'off-map' stations. Absolutely I can add other stations. If you'd like a station to be added, please put a comment in on the Google Forms for Suggestions.

I am not honestly not to sure about the legal side of it. When I made the program, I made sure that the only things I 'copied/ used' were Mutagen and PyGame. I recorded all the announcements myself to avoid any copyright problems. I have integrated the BTP announcement that you linked now, as this is freely available to the public, so I see no issues with it. However, I am not too sure it would be the right thing to use the announcements given on 'https://rail-announcements.davwheat.dev/' due to the possible legal problems.

I have no issues whatsoever with users of my program re-recording the mp3 files to make them their own, or replacing them with external, possibly copyrighted, material for their own, offline, personal use. But versions that I post on TSWC, will not have external content in them, aside from the BTP announcement.

If you wanted to, you could create another txt file and list the stations you want, with the exact same formatting as the other files. Then record/download your own mp3 files and save them in the 'audio_files' folder. Note that the names for the audio files must be exactly the same as the station name in the txt file.

However, please be reminded that, even with your own additions, the base code, functions and my .mp3 files, are not to be re-uploaded.

Thanks very much, Liam-S

Avatar of davwheat
davwheat 19 Dec 2022

It would be understandable from the legal side of things to not bundle them my default, but sending people my way to download the snippet repository from GitHub is another possibility.

Copyright gets tricky. From a FOI point of view, the copyright is not magically revoked when the files are published publicly, so the fact they're available online is not a suitable defence, so I do think the right option is not to publish the recordings here.

I'm more than happy to investigate the idea of automating announcement 'bundle' generation to provide an easy way for people to download a zipped copy of all announcement snippets available through my website, though, if this helps you in any way.

Avatar of TheTrainGuy
TheTrainGuy 25 Sept 2022

Hi,

I've downloaded this and installed, Is it automated annoucements or do i need to close TSW to get to the task bar and then press the desired option?

Thanks.

Avatar of Liam-S-494
Liam-S-494 25 Sept 2022

Hi

You will need to ALT+TAB across to the IDLE window that the program is running in. If you have a second computer, like a laptop, it would preferably be run on there.

Thanks very much, Liam-S

Avatar of scip
scip 27 Sept 2022

can i use it on my second screen ?

Avatar of Liam-S-494
Liam-S-494 27 Sept 2022

Absolutely! Just move the idle window to your other screen and TAB across to it. 👍

Avatar of Activated113
Activated113 5 Oct 2022

This honestly looks and feels great! Lots of customisability and one of the best mods here. Do you have any plans to possibly create a full on program/app out of this, where you could assign keybinds for announcements? Would especially be helpful so I don't have to alt tab while using Touch Portal on my phone.

Avatar of Liam-S-494
Liam-S-494 5 Oct 2022

Hi, thanks very much for the positive words. Yes, I would like to look at this in the future, however I'm a full time student so time is short at the moment. I'm not putting it off completely, but it will be a bit overhaul and unfortunately I don't currently have the time.
Thanks for your understanding. Liam-S

Avatar of joakim
joakim 26 Oct 2022

Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

= RESTART: D:\Program Files (x86)\Train Sim World 3 All dlc\Train Sim World 3\Train Sim Announcer.py
pygame 2.1.2 (SDL 2.0.18, Python 3.10.8)
Hello from the pygame community. https://www.pygame.org/contribute.html

Welcome to Liam's Train Sim Announcer Program
Press CTRL+C to stop the program at any time.

Do you need to restore a previously saved file? 1=YES, 0=NO:
Traceback (most recent call last):
File "D:\Program Files (x86)\Train Sim World 3 All dlc\Train Sim World 3\Train Sim Announcer.py", line 374, in <module>
openfile()
File "D:\Program Files (x86)\Train Sim World 3 All dlc\Train Sim World 3\Train Sim Announcer.py", line 116, in openfile
restore = int(input("Do you need to restore a previously saved file? 1=YES, 0=NO: ")) #asks if user wants to import from txt file
ValueError: invalid literal for int() with base 10: ''

did not work for me can you tell me all this tools works help me

Avatar of Liam-S-494
Liam-S-494 26 Oct 2022

as far as I can see, you did not input anything into the question. Would this be correct?
Thanks

Avatar of M1les
M1les 28 Nov 2022

whenever i get to

'pygame 2.1.2 (SDL 2.0.18, Python 3.10.8)
Hello from the pygame community. https://www.pygame.org/contribute.html

Welcome to Liam's Train Sim Announcer Program
Press CTRL+C to stop the program at any time.

Do you need to restore a previously saved file? 1=YES, 0=NO:'

and i enter my answer the python application immediately crashes

Avatar of Liam-S-494
Liam-S-494 28 Nov 2022

Hi could you send me a screenshot please. Thanks

Avatar of M1les
M1les 28 Nov 2022

have you got discord i can screen share

Avatar of M1les
M1les 28 Nov 2022

M1les#1557

Avatar of M1les
M1les 28 Nov 2022

Avatar of M1les
M1les 28 Nov 2022

thats the bit causing the issue

Avatar of M1les
M1les 28 Nov 2022

if you add my discord i can screen share the crash

Avatar of hololol2
hololol2 29 Nov 2022

Hi,
first thanks for this utility. It really adds to the immersion!

I have a question: How did you create the text-to-speech audio files? (which program/service/...)

Thanks!

Avatar of Liam-S-494
Liam-S-494 29 Nov 2022

Hi, speechelo. Thanks

Avatar of hololol2
hololol2 6 Dec 2022

Thanks!

Avatar of Liam-S-494
Liam-S-494 15 May 2023

Hello everyone, sorry for the lack of updates recently. I have just released a new one which has some minor bug fixes in it. Hopefully this will help the program to run a bit better. My plans for the future are to develop this into a Tkinter program, where it will function like a full-blown app, with buttons that you can press, instead of just using a command line. This is how I would imagine announcements would be generated on real-life trains. If anyone has any more useful feedback, please feel free to add it below.

Thanks very much, Liam-S

Avatar of dwtrains_nz
dwtrains_nz 6 Sept 2023

Hiya. Just started trying the mod. It was working fine on the Bakerloo Line up until I was approaching my 4th stop (Charing Cross). Entered '2' for the Next Stop announcement, the announcement started but when it was about to say the station name the mod crashed. An error message shows up but only for a split second so I'm not entirely sure where the issue lies.

Avatar of dwtrains_nz
dwtrains_nz 6 Sept 2023

I've just tried creating my station list again from scratch. The mod is crashing at the same point.

Avatar of Liam-S-494
Liam-S-494 7 Sept 2023

hi would you be able to send me some screenshots please?
Most likely the audio file could not be found.
Thanks

Avatar of dwtrains_nz
dwtrains_nz 8 Sept 2023

The screenshot with the error message took rather a lot of attempts to get. Finally got my timing right.

Avatar of Liam-S-494
Liam-S-494 8 Sept 2023

Please go to the folder named 'texttospeech_audio_files' and find the file called 'londoncharringcross.mp3' and rename it to 'LondonCharingCross.mp3'.

This should fix the issue. Thanks

Avatar of Liam-S-494
Liam-S-494 30 Sept 2023

Hi, did this work?

Avatar of .erek
.erek 20 Oct 2023

This is absolutely super neat and implements one of my most sought after features! Can't believe they still haven't got any kind of basic implementation of this.

Avatar of Liam-S-494
Liam-S-494 20 Oct 2023

Thanks for your kind comments. I am currently doing my A-Level Computer Science course, second year, and as part of my project, I will be upgrading this and giving it a whole new updated look, as if it would be on a touchscreen in a real train! This update should be out by April at the latest!

Avatar of Apple
Apple 21 Jan 2024

Hey Liam,

Just want to say what a fantastic new update you published. Your program is so neat! I was using the last version for quite a while.

The GUI is great. I figured out how to add custom templates to the DB. I am going to see about adding some German routes.
Just a quick question:
I tried changing the window from fullscreen to windowed (1200x800) by changing x.state("zoomed") to x.geometry(1200x800) which works, but when clicking a button, the previous screen does not clear and the announcement screens do not progress (effectively holding/hanging) until manually closing the window. Would you know why by any chance? I am not an expert at python by any means.

Kind regards,
Apple

Avatar of Liam-S-494
Liam-S-494 22 Jan 2024

Hello! Thanks very much for the comments. Glad you like the program.

In ref to the window not closing. The program specifically looks for the window state to be 'zoomed'. If it is not, then the window cannot be found when the 'close()' subroutine is run. Therefore meaning that the window is not closed when a new one is opened. Can I ask why it is that you're changing the resolution? Might be able to work with the request and I'll have a look at the code.

Liam

Avatar of m;
m; 19 Feb 2024

Hi there, how would I create my own preset, would it just be a case of putting the stations into a .txt file, or would it need CRS codes in it instead?

Avatar of Liam-S-494
Liam-S-494 19 Feb 2024

Hi, the ability to add presets is coming soon!
Thanks

Add a comment

If you wish to leave a comment, please log in .

About this mod

Created
24 Sept 2022
Updated
17 Jan 2024
Game
Train Sim World
Type of content
Utility
Train Sim World compatibility
Train Sim World 2 before Rush Hour update (UE4 4.23), Train Sim World 2: Steam version (UE4 4.26), Train Sim World 2: Epic Games Store version (UE4 4.26), Train Sim World 3, Train Sim World 4
Train Sim World Content
Bakerloo Line, Birmingham Cross-City Line, Great Western Express, Isle Of Wight: Ryde - Shanklin, Northern Trans-Pennine: Manchester - Leeds, Rush Hour - London Commuter - Brighton Main Line: London Victoria - Brighton, Southeastern Highspeed, West Cornwall Local: Penzance - St Austell & St Ives