Skip to main content

A Python tool to translate text to Morse code audio using various voices.

Project description

Echo-Morse

CI PyPI version License: MIT

a.k.a. 摩斯電狗 (Morse the E-Dog)

A versatile tool for converting text to Morse code (CW) with customizable audio synthesis, designed for HAM radio operators and enthusiasts.

Features

  • Convert text to/from Morse code notation
  • Generate CW audio with customizable voices and parameters
  • Support for ham radio abbreviations and prosigns (e.g. CQ, SK, AR, etc.)
  • Adjustable speed, timing, and sound characteristics

For planned enhancements and upcoming features, see our TODO list.

Installation

From PyPI (Recommended)

The easiest way to install Echo-Morse is via pip:

pip install echomorse

This will install the package and make the echomorse command available in your environment.

From Source

  1. Clone the repository:
    git clone https://github.com/baksili/echo-morse.git
    cd echo-morse
    
  2. Install with PDM: PDM is used for managing dependencies and the project environment.
    pdm install
    
    This installs the package and its dependencies. The echomorse command will then be available within the PDM environment (e.g., via pdm run echomorse ...) or globally if you activate the PDM virtual environment or install it globally.

Basic Usage

All commands are run using the echomorse entry point. If you've installed via pip, you can simply run echomorse <command>. If you've installed from source using PDM, you can run via pdm run echomorse <command>.

Convert text to Morse code notation:

echomorse text2code "CQ DX"
# Shorter alias:
echomorse t2c "CQ DX"

Convert Morse code notation to text:

echomorse code2text ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."
# Shorter alias:
echomorse c2t ".... . .-.. .-.. --- / .-- --- .-. .-.. -.."

Convert text directly to Morse code audio:

echomorse text2audio "CQ CQ DE BY1QH" --output cq_call.wav
# Shorter alias:
echomorse t2a "CQ CQ DE BY1QH" -o cq_call.wav

Direct Playback:

You can pipe the audio output directly to an audio player. ffplay (from the FFmpeg project) is recommended for its robust support for stdin streaming.

echomorse t2a "SOS" -o - | ffplay -i - -nodisp -autoexit

N.B. Unlike many other commands, afplay on macOS doesn't reliably support reading from stdin. If you're using macOS, install ffplay via Homebrew (brew install ffmpeg) for this functionality.

Convert Morse code notation directly to audio:

echomorse code2audio "... --- ..." --output sos.wav
# Shorter alias:
echomorse c2a "... --- ..." -o sos.wav

Direct Playback:

Using ffplay:

echomorse c2a "TEST" -o - | ffplay -i - -nodisp -autoexit

List available voices:

echomorse list-voices
# Show detailed information about each voice:
echomorse list-voices --detailed

Piping Examples

Echo-Morse commands are designed to work with Unix-style pipes. Input arguments for text or Morse code can be piped from stdin.

# Convert text to Morse code via pipe, then to audio
echo "HELLO WORLD" | echomorse t2c | echomorse c2a -o pipe_hw.wav

# Process text from a file using cat and pipe to text2audio
cat message.txt | echomorse t2a -o message_from_file.wav --wpm 25

# Save Morse code to a file, then pipe its content to code2audio
echo "TEST" | echomorse t2c > morse_output.txt
cat morse_output.txt | echomorse c2a -o audio_from_morse_file.wav

Command Options and Help

All commands and subcommands support -h or --help for detailed usage information:

echomorse -h
echomorse text2audio -h

Common audio generation options:

# Specify a voice and speed (WPM)
echomorse t2a "SOS" --voice dog_bark --wpm 15 -o sos_dog.wav

# Control fade type and value (e.g., 10% fade)
echomorse t2a "HELLO" --fade-type percentage --fade-value 10 -o hello_fade_p.wav

# Control fade type and value (e.g., 15ms absolute fade)
echomorse t2a "WORLD" --fade-type absolute --fade-value 15 -o world_fade_abs.wav

# Set the normalization level (in dBFS)
echomorse t2a "CQ" --target-dbfs -18 -o cq_louder.wav

# Adjust pattern matching probability for voices with sequence patterns
echomorse t2a "CQ DE BY1QH" --voice dog_bark --pattern-chance 0.5 -o cq_dog_less_pattern.wav

Voice System Explained

The voice system allows for customizable audio outputs beyond simple tones. Each voice is a collection of audio files and configuration settings.

Voices are stored in the audio directory with each voice in its own subdirectory (e.g., audio/my_custom_voice/).

Each voice directory must contain:

  1. A voice_config.json configuration file.
  2. Audio files (e.g., .wav) referenced in the configuration.

Voice Configuration (voice_config.json)

Defines:

  • Basic voice metadata (name, description).
  • Audio files for Morse elements (e.g., dot, dash).
  • Optional sequence_patterns for mapping specific Morse sequences (like ... --- ...) to custom audio files (e.g., a single recording of "SOS").

Example:

{
  "name": "my_voice",
  "description": "My custom voice for Morse code",
  "elements": {
    "dot": "dot_sound.wav",
    "dash": "dash_sound.wav",
    "custom_sos_sound": "sos_recording.wav" // A full recording for SOS
  },
  "sequence_patterns": {
    "custom_sos_sound": "... --- ..." // Maps the Morse for SOS to the element key "custom_sos_sound"
  }
}

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

echomorse-0.8.1.tar.gz (248.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

echomorse-0.8.1-py3-none-any.whl (239.8 kB view details)

Uploaded Python 3

File details

Details for the file echomorse-0.8.1.tar.gz.

File metadata

  • Download URL: echomorse-0.8.1.tar.gz
  • Upload date:
  • Size: 248.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.19.3 CPython/3.11.11 Darwin/24.2.0

File hashes

Hashes for echomorse-0.8.1.tar.gz
Algorithm Hash digest
SHA256 3a9229512bbb4b75235b66d9178c207aafe26e34342076823aee0ce0c0ad7d84
MD5 f94f0c817f335e9e4c0ffcaa11a02f56
BLAKE2b-256 f0790448b257602da5767b8ad36f423be4fd55fb851221d0558ef8e4ede2e1c6

See more details on using hashes here.

File details

Details for the file echomorse-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: echomorse-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 239.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.19.3 CPython/3.11.11 Darwin/24.2.0

File hashes

Hashes for echomorse-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 748be11234d2c490cf462b347b398091b6e496fea1df4080815c67374add4152
MD5 c32bec72c6d49c070ea0b53c7512d1c8
BLAKE2b-256 11fb0dfb6085e2ba248908914068bfcae0239ba53c9041765b5cb219e1890288

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page