A real-time morse code audio player that converts your keyboard input into morse code beeps. Type any letter, number, or space and hear it immediately played back as morse code audio signals.
- Real-time conversion: Converts letters A-Z, numbers 0-9, and spaces to morse code
- Audio playback: Plays morse code using system beeps (750 Hz frequency)
- Proper timing: Follows international morse code timing standards
- Threaded processing: Non-blocking keyboard input with queued audio processing
- Cross-platform: Works on Windows (uses
winsoundfor audio)
- Python 3.6+
- Windows OS (for
winsoundmodule) - Required packages (see
requirements.txt):pynput- For keyboard input detection
- Clone or download this project
- Install the required dependencies:
pip install -r requirements.txt
-
Run the program:
python morse_code.py
-
Start typing on your keyboard:
- Letters A-Z: Converted to morse code and played immediately
- Numbers 0-9: Converted to morse code and played immediately
- Space: Plays a longer pause (word separation)
- ESC: Exit the program
-
The console will display each character and its corresponding morse code pattern as you type.
Type something (ESC to quit)...
H: ....
E: .
L: .-..
L: .-..
O: ---
:
W: .--
O: ---
R: .-.
L: .-..
D: -..
- A:
.-B:-...C:-.-.D:-..E:.F:..-. - G:
--.H:....I:..J:.---K:-.-L:.-.. - M:
--N:-.O:---P:.--Q:--.-R:.-. - S:
...T:-U:..-V:...-W:.--X:-..- - Y:
-.--Z:--..
- 1:
.----2:..---3:...--4:....-5:..... - 6:
-....7:--...8:---..9:----.0:-----
The program follows international morse code timing standards:
- Dot duration: 100ms (1 unit)
- Dash duration: 300ms (3 units)
- Intra-character space: 100ms (1 unit) - gap between dots/dashes within a character
- Inter-character space: 300ms (3 units) - gap between characters
- Word space: 700ms (7 units) - gap between words
- Main thread: Handles keyboard input detection using
pynput - Worker thread: Processes morse code conversion and audio playback
- Queue system: Buffers keystrokes for smooth audio playback without blocking input
- Uses Windows
winsound.Beep()function - Fixed frequency of 750 Hz for all morse code signals
- Variable duration based on dot/dash timing
- Windows only: Uses
winsoundmodule which is Windows-specific - English characters only: Supports A-Z, 0-9, and space
- No punctuation: Special characters and punctuation are not supported
- System audio: Relies on system's ability to produce beep sounds
You can modify the following constants in morse_code.py to customize the behavior:
UNIT_DURATION = 100 # Base timing unit in milliseconds
# Adjust this to make morse code faster (lower) or slower (higher)The audio frequency can be changed by modifying the 750 value in the winsound.Beep(750, duration) calls.
Feel free to submit issues, feature requests, or pull requests. Some potential improvements:
- Add support for punctuation marks
- Cross-platform audio support (Linux/macOS)
- Adjustable speed settings
- Visual morse code display
- Save/load morse code messages
This project is open source and available under the MIT License.