I considered two buttons early on, however, that's not necessary. The issue isn't separating dots from dashes. That part works very well - in fact, I don't recall the decoder making an error between a dot and a dash in a very long time.
The code even handles when there are only dots, or only dashes now, such as:
. . . .
which is "se" and:
- - - -
which is "ot"
The issue is the spaces between symbols, letters, and words. Theses are all multiples of the dot-length. If sending a lot of text, and the sending speed changes over time, then the symbol-space, the letter-space, and the word-space, can become ambiguous across the entire message. (Usually, the symbol space is fine, but the letter space and word space can drift close together).
There really needs to be a mix of short-term and long-term tracking of space lengths, so if the sending speed drifts, the code adapts in real time.
The downside of the poor space tracking that sentences can end up as:
"T h e dow nsi deof thep o o r sp ace t ra ckin g th at s en t en ces ca n endup as:"
It's not usually that bad though, the typical case is that a few extra spaces, which are due to word separations, are thrown in the middle of the text. Usually all the letters are correct, because the symbol space is the same as a dot, and that's usually about a third of the letter spacing. If sending very fast, even the symbol space can get messed up though, which results in combining letters, sometimes changing a letter, and sometimes producing an invalid character. Invalid characters are currently silently discarded. That could be improved too, by having the code try to parse the combined invalid symbols into one or more valid characters. (I probably will never do this though, as that's compute-intensive, and requires a dictionary and even could require natural language analysis).
The space threshold problem can be alleviated by exaggerating the separation between letters and words when sending the text, but this sounds unnatural to someone familiar with Morse code. It also feels very unnatural to change the proper flow of Morse code. Imagine reciting letters, and doing really long pauses between letters and really, really long pauses between spelled words.
Also, if I work very hard at having a consistent sending speed, the program does much better. But human beings typically allow their speed to vary, just as they do when speaking, particularly if there are distractions, so that's not a good long-term solution.
The human brain has an easy time doing real-time tracking of the spaces between symbols, letters, and words in Morse code, and adjusting based on sending speed and content.
I think if I work on it long enough, I can get the space tracking to work much better. I have a number of ideas I think that will improve that.
Also, right now, I enter Morse code data on the screen, stop entering data, and then wait two seconds for the system to recognized I've stopped and process all the data. A better system would be real-time decoding as the data flows in, with some buffering to allow estimation of thresholds in real-time.
Another competently different idea I want to try is to be able to draw individual characters on the screen, and having those get recognized, i.e. crude OCR of large hand drawn characters. That would be a fun and challenging project. I saw the Sketch.py sample program. That's a good starting point for the input part of that program. For now though, I want to improve the Morse Code decoder.