Skip to main content

Encode, decode & play Morse code easily

Project description

Logo

License

Requirements

Python Version pygame Version

Introduction

MorseCodePy is a versatile Python module that streamlines the encoding and decoding of text into Morse code and back. With support for multiple languages, including English, Russian, Ukrainian, Spanish, French, as well as provisions for handling numbers and other special characters, this module offers a powerful and user-friendly Morse code tool.


Usage

encode(string, /, language, *, dot, dash, error)

Encode a text string into Morse code.

  • string: The text string you want to encode.
  • language: The target language for encoding ( e.g., english, french, spanish, russian, ukranian, numbers, special).
  • dot: (optional) Symbol to represent dots (default is .).
  • dash: (optional) Symbol to represent dashes (default is -).
  • error: (optional) Symbol to represent errors when an unknown character is encountered (default is *).
from MorseCodePy import encode

encoded_string = encode('Hello, world!', language='english')
print(encoded_string)
# Output: .... . .-.. .-.. --- --..-- / .-- --- .-. .-.. -.. -.-.--
from MorseCodePy import encode

encoded_string: str = encode('10 pièces !', language='french')

print(encoded_string)
# Output: .---- ----- / .--. .. .-..- -.-. . ... / -.-.--

decode(code, /, language, *, dot, dash, error)

Decode Morse code into a text string.

  • code: The Morse code string you want to decode.
  • language: The target language for decoding ( e.g., english, french, spanish, russian, ukranian, numbers, special).
  • dot: (optional) Symbol to represent dots (default is .).
  • dash: (optional) Symbol to represent dashes (default is -).
  • error: (optional) Symbol to represent errors when an unknown Morse code sequence is encountered (default is *).
from MorseCodePy import decode

decoded_string = decode('···· · ·-·· ·-·· --- --··-- / ·-- --- ·-· ·-·· -·· -·-·--', language='english', dot='·')
print(decoded_string)
# Output: hello, world!

play(code, /, delay, volume, *, dot, dash, separator)

Play Morse code sound.

  • code: The Morse code you want to play.
  • delay: (optional) The delay in seconds between characters (default is 0.5).
  • volume: (optional) The volume of the Morse code playback (default is 1.0).
  • dot: (optional) Symbol to represent dots (default is .).
  • dash: (optional) Symbol to represent dashes (default is -).
  • separator: (optional) Symbol to represent separators (default is /).
from MorseCodePy import encode, play

encoded_string: str = encode('Hello', language='english')

play(encoded_string, delay=0.5, volume=0.8)

chart(*, dot, dash)

Print a Morse code chart in the console.

  • dot: (optional) Symbol to represent dots (default is ·).
  • dash: (optional) Symbol to represent dashes (default is -).
from MorseCodePy import chart

chart(dot='·')

Contact

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

morsecodepy-3.7.tar.gz (145.5 kB view details)

Uploaded Source

Built Distribution

morsecodepy-3.7-py3-none-any.whl (144.9 kB view details)

Uploaded Python 3

File details

Details for the file morsecodepy-3.7.tar.gz.

File metadata

  • Download URL: morsecodepy-3.7.tar.gz
  • Upload date:
  • Size: 145.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for morsecodepy-3.7.tar.gz
Algorithm Hash digest
SHA256 5106d3ec0053cbc85a534e9d73512b042aa1a0abc9524539e76f9d3722667a31
MD5 78c92c9f2ecd524a0646f76fe7603b6f
BLAKE2b-256 2fc926e6031e55c71c01b91e8336d112e8e30ade089000a211a86cf0ac16ab76

See more details on using hashes here.

Provenance

File details

Details for the file morsecodepy-3.7-py3-none-any.whl.

File metadata

  • Download URL: morsecodepy-3.7-py3-none-any.whl
  • Upload date:
  • Size: 144.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for morsecodepy-3.7-py3-none-any.whl
Algorithm Hash digest
SHA256 035167c670d054a1a4a20ff7fab17ffb8f547fe167f6d2e075e18987a4cdc98e
MD5 5cdff7799c9c29518eb4cdaa66971a70
BLAKE2b-256 1845f8bc991464f0408ab1546e9a729dcac534e34ebb7799daeec7568867b9c1

See more details on using hashes here.

Provenance

Supported by

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