This repository provides a Python application for converting text into Morse code and playing it in real-time. Designed to run on the NVIDIA Jetson Orin Nano Developer Board, the application streams audio directly to a connected speaker.
- Real-Time Text-to-Morse Conversion: Converts incoming text into Morse code and streams the audio live.
- Customizable Speed: Supports configurable playback speeds in Words Per Minute (WPM).
- Simulated or Live Input: Works with simulated text streams, file input, or other live data sources.
To run this application on your Jetson Orin Nano Developer Board, ensure the following dependencies are installed:
pip3 install torchaudio torch
aplay: A command-line audio playback tool, usually available with thealsa-utilspackage.
Install with: sudo apt-get update sudo apt-get install alsa-utils
-
Audio Output Configuration:
- Ensure your USB or HDMI audio device is detected. Use the following command to list audio devices: aplay -l
- Replace
plughw:2,0in the code with the appropriate device from your system.
-
Development Environment:
- Python 3.6+ is required. Ensure you have access to the
pippackage manager.
- Python 3.6+ is required. Ensure you have access to the
The application adheres to standard Morse code timing:
- Dot Duration: ( 1.2 / ext{WPM} )
- Dash Duration: ( 3 imes ext{Dot} )
- Space Between Symbols: ( 1 imes ext{Dot} )
- Space Between Characters: ( 3 imes ext{Dot} )
- Space Between Words: ( 7 imes ext{Dot} )
-
Text-to-Morse Conversion:
- Converts incoming text into Morse code using a dictionary lookup.
-
Waveform Generation:
- Uses
torchto generate sine wave tones for dots and dashes, and silence for spaces.
- Uses
-
Real-Time Playback:
- Streams generated audio waveforms to
aplayfor immediate playback.
- Streams generated audio waveforms to
-
Clone the repository: git clone https://github.com/ValidusGroup-Design/realtime-morse-code.git cd realtime-morse-code
-
Run the application: python3 continuous_morse_playback.py
-
To use custom input (e.g., from a file), modify the
text_streamfunction: def file_text_stream(filepath): with open(filepath, "r") as file: for line in file: yield line time.sleep(0.5) # Delay between lines -
Replace the simulated stream with: play_morse_realtime(file_text_stream("book.txt"), wpm=20)
This application demonstrates how to:
- Generate audio waveforms programmatically using
torchandtorchaudio. - Stream audio directly to a playback tool (
aplay) in real time.
Key aspects include:
- Adhering to international Morse code timing standards.
- Efficiently managing dot, dash, and spacing durations.
The application is modular, making it easy to:
- Integrate with other input sources (e.g., network streams).
- Extend functionality (e.g., add GUI for input).
Running the application with the text "DE WF9Q" at 20 WPM:
- Input:
DE WF9Q - Generated Morse:
-.. . / .-- ..-. ----. --.-
The generated Morse code audio will be streamed and played via your system's audio device.
Feel free to submit issues or pull requests to improve this project. Contributions are always welcome!
This project is licensed under the MIT License. See LICENSE for more information.