Hello,
After a little fumbling around I cobbled together a little program that can take a text message (with some limitations) and play and write out the morse message. It's pretty simple. Maybe it can be helpful for other beginners. Of course, would also be happy to try to update if there are better ways of doing things.
The code is: GitHub - adilhasan/morse_code: Small rust program to encode a message into morse
hope you have a very good day, adil