A small NiceGUI-based training app that plays single characters in Morse code and measures your reaction time. Built for quick practice sessions to improve Morse recognition speed.
Features
- Play a random character in Morse code and await a single-key response
- Tracks reaction time for correct answers and marks incorrect attempts
- Configurable session length and WPM (words per minute) speed
- Auto-replay after 1.5 seconds if no response
- Session-based training with Start/Stop controls
- SQLite database for persistent session history
- History tab with:
- Recent sessions table showing date, WPM, duration, accuracy, and average response time
- Character statistics grid with color-coded accuracy (green ≥90%, yellow ≥75%, red <75%)
- Export to CSV functionality
- Clear history option with confirmation dialog
- Response time sparkline chart during active sessions
- Bell sound at the end of a session
- Native app mode (optional, via
--nativeflag)
Requirements
- Python 3.12+ (project uses 3.13 in the workspace)
- The project already depends on
nicegui(seepyproject.toml). The app also usesnumpyandsounddevicefor audio.
If you use uv for package management (as in this project), add the runtime packages with:
uv syncOr with pip:
python -m pip install nicegui numpy sounddevice pywebviewNote: pywebview is only needed if you want to run in native app mode.
How to run
Browser mode (default):
uv run python main.pyThen open your browser to http://localhost:8080
Native app mode:
uv run python main.py --nativeOpens as a native window using pywebview (no browser required).
On AlmaLinux, you may need to set an environment variable:
WEBKIT_DISABLE_COMPOSITING_MODE=1 uv run python main.py --nativeDebug mode:
uv run python main.py --debugPrints additional logs to the console. Can be combined with --native.
Quick usage
Starting a session:
- Adjust the "Session Length" (seconds) and "WPM" (words per minute) settings
- Click "Start" to begin - there's a 1-second buffer before the first character plays
- Listen to the Morse code character and type the letter you heard
- If correct, your reaction time is recorded; if incorrect, the error is logged and you can try again
- If you don't respond within 1.5 seconds, the character automatically replays
- Click "Stop" to end the session early (a bell sound plays when finished)
Viewing history:
- Switch to the "History" tab to see:
- Recent sessions with accuracy, average response time, and other stats
- Character-by-character statistics showing which letters need more practice
- Click "Export CSV" to download your session data for external analysis
- Click "Clear History" to reset all data (requires confirmation)
Notes and customization
- Audio is generated in-code using
numpyand played withsounddevice. If your system has no audio devices orsounddevicefails, the app will still run but you won't hear prompts. - The Morse timing use the PARIS formula according to WPM slider.
- The UI uses NiceGUI; it's straightforward to extend the interface (add charts, summaries, or export results).
Troubleshooting
- If the server fails to start, check the terminal logs. NiceGUI prints the address (e.g., http://localhost:8080).
- Run with
--debugflag to print additional logs to the console. - If audio playback fails: ensure your system has an audio output device and that
sounddevicewas installed successfully. - If native mode doesn't work, ensure
pywebviewis installed and you have the required system dependencies (WebKit on Linux, WebView2 on Windows). - Session history is stored in
~/.morse_echo.db- if you encounter database errors, you can delete this file to start fresh.
License
- MIT
Authors
- N7LFO (Andy)
