Skip to main content

Morse2sound

What can I do with this?

From some text, produce a sound file that contains that text, encoded in Morse code.

Background

What's this Morse code thing?

Fast message transport via telegraphy was one of the first practical uses of electricity, dating back to the middle of the 19th century.

Samuel F. B. Morse originally devised a scheme to transmit numbers via electric pulses, with a code book that allowed translation of words to those numbers and back. Later, his assistant Alfred L. Vail improved on this by coding single letters, so the code book became obsolete. He used short, long, longer, and extra long impulses. His original method is still remembered as American Morse Code, although it sees little use. This was again improved by Friedrich C. Gerke, who simplified from four different impulse lengths to just two. Gerke's code is virtually identical to what is nowadays known as International Morse Code. In 1865, an international treaty established the ITU as the first multinational standards organization, with the purpose of facilitating cross-border transport of messages. That same 1865 treaty also formalized Gerke's version of the Morse code. The coding of the letters a-z and the digits 0-9 have remained unchanged since then, but other things like punctuation indeed have seen some changes. The ITU still exists and to this day standardizes the international Morse code, among many other things.

Is anybody still using Morse telegraphy?

Morse telegraphy is still extensively used by certain sections of the HAM amateur radio community. For obscure historical/technical reasons, Morse telegraphy is generally designated as "CW".

CW is ubiquitous. On an everyday basis, any CW-capable short wave receiver (such as Twente Web-SDR available on the internet) is likely to pick up CW signals if tuned through the designated telegraphy ranges, e.g., 7000-7040 kHz. CW sees extensive use among DXers (radio amateurs trying to reach rare far-away places), in contests (radio amateur competitions), and by the "home-brew" community (radio amateurs constructing their own equipment). By its supporters, CW is considered an enjoyable mode of operation.

Usage

What does this software do?

It takes text and produces, as a sound file or stream, a Morse encoded version of that text.

The output format is that of .wav files.

Basic usage

morse2sound --in message.txt --wpm 12 --out message.wav

You can

  • Hand in text as a file or as a command line argument.
  • Control what should happen for characters like ! not present in the Morse alphabet.
  • Control the sample rate, amplitude, and number of channels (mono/stereo) of the output file.
  • Control the speed and also generate Farnsworth.
  • Set a frequency (range) for the audio frequency generated.
  • Experiment with ramp-up and ramp-down "skirt times" different from the standard 5 ms.
  • Choose between linear and raised cosine skirts.

For details, do morse2sound --help or morse2sound -h .

Character set

The international Morse code.

On Morse speed

TODO: Explain the norm word "Paris ".

Installation

Install Python. Make sure when you say python3, then a resonably recent version of Python comes up. In particular, python3 --version should give a 3.10.something or later version. If in doubt, install the newest 3.14.

This software could be easily backported to 3.9 or 3.8, it's only typing hints that require 3.10 or better. (Previous published versions also needed 3.10 or better, but claim to make do with 3.8 or 3.9. This was a bug. It has been fixed with 1.0.3: The software now correctly says it needs Python>=3.10.)

Create and activate a virtual environment as per the documentation pertaining to your OS. In particular, on Linux, it boils down to:

python3 -m venv venv
. venv/bin/activate

Install

pip install morse2sound

Side remark: Compression

The .wav files generated compress quite well, with the compression algorithm of your choice, zip or something.

Contributing

Have git installed.

git clone https://gitlab.com/4ham/morse2sound.git

Change to the directory morse2sound that was created by the above.

Create and activate a virtual environment as per the documentation pertaining to your OS.

Then:

pip install -r requirements_test.frozen
./lint.py

Do your changes and repeat that python ./lint.py part in your branch before starting a pull request as usual towards the repository.

To run locally

PYTHONPATH=$(pwd)/src python src/cw_enc/driver.py -h

To build locally

In an activated virtual environment:

pip install --upgrade build
rm -rf dist build src/morse2sound.egg-info
python -m build

To install what you built:

pip install dist/morse2sound-*-py3-none-any.whl

To upload

This is useful only for the maintainer:

Extended tests with pip install doit && doit --verbosity 2 .

  • Edit the version in pyproject.toml
  • git tag -s vx.y.z
  • git push origin --tags
pip install --upgrade build twine
rm -rf dist build src/morse2sound.egg-info
python -m build
python -m twine upload dist/*

Metadata

Release files for morse2sound 1.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for morse2sound 1.0.6
File Size Uploaded
morse2sound-1.0.6.tar.gz 20.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for morse2sound 1.0.6
File Interpreter ABI Platform
morse2sound-1.0.6-py3-none-any.whl Python 3 none any Details

Total release size: 37.2 kB

Release files / morse2sound-1.0.6.tar.gz

Download URL morse2sound-1.0.6.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
34c17494e1543fa5100882e6e469fd71dcf301e7c8a54b4ad42fa2f982645056
BLAKE2b-256 checksum
How to use checksums
b16f042e3897d078d2e4dcbcebb5421c3b93799e10ba057ced89bd159478bc08
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / morse2sound-1.0.6-py3-none-any.whl

Download URL morse2sound-1.0.6-py3-none-any.whl
Size 16.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e858147c36a8e86527b2f917baa0d7cdb7a27a4e462204ce8d7204d16d1a25fa
BLAKE2b-256 checksum
How to use checksums
b45c28c18d3c4c3c2aa5e6ca6d796d6ebf88ecaff0007fd25be5c3dced0aae2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

1.0.6 This release

2 release files

1.0.5

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page