Python Forum
Morse Code Practice Script - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Code sharing (https://python-forum.io/forum-5.html)
+--- Thread: Morse Code Practice Script (/thread-7636.html)

Pages: 1 2


Morse Code Practice Script - sparkz_alot - Jan-18-2018

I created this script for myself which I thought I would share for those interested in learning or improving their Morse Code skills. I have not included all possible tests, but if you follow the menu items, 1 than 2 than 3, you should be o.k. The script will create a group of 5 random characters per word depending on the file type selected. The number of 'words' is determined by line 45, in this case it is set for 10 words, though for myself, I set it for 500 or (range(2500)).

The 'Words per minute' (wpm) are based on the formula from the ARRL (American Radio Relay League) site located here:
http://www.arrl.org/files/file/Technology/x9004008.pdf.

I suggest not going above 70 wpm because, at least for my sound system, it becomes to distorted.

As for the frequency, I would suggest starting with 400 and adjusting from there to suit your tastes. This value must be given in Hertz.

The file 'code_file.txt' will be created in the working directory.

One final note, although I've included all characters in the standard Morse Code, there is one that I had to skip and that is the single 'close quote' or back slant quote. There is no equivalent on the keyboard, so I tried to use the Unicode equivalent, but this raises an error I can't figure out how to correct (see line 98).

EDIT: The error has been corrected in the included code posted here

Lastly, if you don't want to see the answer printed on screen, comment out line 168.

As always any comments, critisisms, improvements are appreciated.

Enjoy.




RE: Morse Code Practice Script - Larz60+ - Jan-18-2018

QSL


RE: Morse Code Practice Script - Skaperen - Jan-24-2018

next, i'd like a program to take audio in, in real time, and decode all morse code streams being heard (with SSB wide filters, you often get many streams), showing each stream as a separate horizontally scrolling line. if the streams are too close, i can understand them not being separated. but it is amazing what DSP (software) can do that hardware (filters) cannot for separating signals, even with wide bandwidths (due to high modulation rates).


RE: Morse Code Practice Script - Larz60+ - Jan-24-2018

Morse to text: https://code.google.com/archive/p/morse-to-text/source/default/source
(don't think it's python)
there are .py files...


RE: Morse Code Practice Script - league55 - Jan-24-2018

Did you try the configparser module for the configuration?


RE: Morse Code Practice Script - sparkz_alot - Jan-24-2018

(Jan-24-2018, 10:46 AM)league55 Wrote: Did you try the configparser module for the configuration?

I did not, no. I had thought about a config file at the beginning, but there didn't seem to be enough options to justify one.

Quote:next, i'd like a program to take audio in, in real time, and decode all morse code streams being heard (with SSB wide filters, you often get many streams), showing each stream as a separate horizontally scrolling line.

There are certainly some very good programs out there that do just that and encompass several, if not all, digital modes (including Morse).

Quote:Morse to text:

Come on Larz, that's just flat out cheating Angel


RE: Morse Code Practice Script - Larz60+ - Jan-24-2018

No, It's a fun project.
I'm a big cw fan, though haven't been on air for quite some time.
When I am, I like QRP, and use a Yaesu FT-817 with an Alexloop antenna.
Lots of fun.


RE: Morse Code Practice Script - league55 - Jan-24-2018

Another thought is that words(>18wpm) and words(<18wmp) look a lot like two objects of the Words class. They have all (or nearly all) of their attributes in common and the values of the attributes are just different. But I don't know whether defining a class for just two objects would be worth it. Maybe if there were some reason to make that wmp value a (variable) attribute too, or to have one for a minimum and one for a maximum value, but I don't know enough about the use case to know whether that even makes any sense. (E.g. you can define a Birthday class and overload the __add__ and __radd__ operators to add two birthdays together with the expression birthday1 + birthday2, but why? I don't know if I'm talking about the same kind of folly here.)


RE: Morse Code Practice Script - Skaperen - Jan-25-2018

in morse to text you don't know the wpm in advance but can figure out dits and dahs to an extent ... enough to evaluate them where the speed remains close over some number of them. the real fun happens when two signals are so close that their sidebands overlap. even more fun happens when a 3rd signal is near these 2. then it is not a simple as cutting off the sidebands between 2 signals as you would destroy the middle signal. you need to demod the 2 outer signals (demod whatever comes through ok) and reproduce it and subtract. you now have a "2nd layer" of signals to demod and decode. this can work to some extent because morse code and A1 modulation is actually very redundant. don't expect to do much with overlapping digital signals in use today.


RE: Morse Code Practice Script - sparkz_alot - Jan-31-2018

Just an update, I made some changes to the original code posted above (thought it was better than re-posting the entire code again).

Line 98: added the 'single close quote' (\u00b4) back into the punc string, so it now reads:
punc = '.,?`!/()&:;=+-_$@\u00b4'    # ยด = '\u00b4'
Line 164: added encoding to the open statement, so it now reads:
with open('code_file.txt', 'r', encoding='utf-8') as file:
I will try and run it on Linux this weekend to make sure in works on that OS as well.