Skip to main content

A python module for interacting with morse code

Project description

py_simple_morse_code 0.0.1


About^

A python module for interacting with morse code

GUI Usage^

Install with pip install py_simple_morse_code. To launch the gui run python -m py_simple_morse_code

Requirements^

pyaudio scipy numpy

Classes^

SignalProcessor^

Non-blocking CW signal processor. The .process() method returns true if a CW tone was found in the signal.

class SignalProcessor(object):
	def __init__(self, mic_index: int = 0, min_tone: int = 600, max_tone: int = 1500, sample_size: int = 512, sample_rate: int = 32000, high_pass_frequency: int = 4, low_pass_frequency: int = 10000):
		...
	def end_session(self) -> None:
		"""Ends the audio stream. *Returns None*"""
	def process(self) -> bool:
		"""Process a chunk of the audio stream from the buffer. *Returns None*"""
	def start_session(self) -> None:
		"""Start the audio stream. *Returns None*"""

MorseCodeTranslator^

A low-level morse code translator. Inputs should be debounced / sanitized before being passed to the .update(state:bool) method. Tolerance only affects word-sep deadbeats to account for hesitation / early resumes between words.

class MorseCodeTranslator(object):
	def __init__(self, words_per_minute: int = 24, debounce_time: float = 0.01, tolerance: int = 0):
		...
	def update(self, state: bool) -> None:
		"""Call this whenever input state changes. Alternatively call this at a set frequency with the current state. *Returns None*"""

Functions^

encode_string_to_morse^

Encodes text to morse code dots and dashes. Returns a string

def encode_string_to_morse(in_str: str, short_char: str = '.', long_char: str = '-', sep_char: str = ' ', replace_on_unknown: bool | str = '?', verbose: bool = True) -> str:
> 	...

encode_string_to_beats^

Converts a plaintext string to a beats list. Returns a list of bools

def encode_string_to_beats(in_str: str, verbose: bool = True) -> list:
> 	...

encode_string_to_waveform^

Encode a plaintext string to a waveform. Returns a float32 1-dimensional numpy array

def encode_string_to_waveform(in_str: str, tone: int = 1000, words_per_minute: int = 24, sample_rate: int = 32000, verbose: bool = True) -> numpy.ndarray:
> 	...

encode_morse_to_beats^

Converts dots and dashes to a beats list. Returns a list of bools

def encode_morse_to_beats(morse: str, verbose: bool = True) -> list:
> 	...

encode_morse_string_to_waveform^

Encode a morse string to a waveform. Returns a float32 1-dimensional numpy array

def encode_morse_string_to_waveform(morse: str, tone: int = 1000, words_per_minute: int = 24, sample_rate: int = 32000, verbose: bool = True) -> numpy.ndarray:
> 	...

encode_beats_to_waveform^

Encode a beats list into a waveform. Returns a float32 1-dimensional numpy array

def encode_beats_to_waveform(beats: list, tone: int = 1000, words_per_minute: int = 24, sample_rate: int = 32000, verbose: bool = True, volume: float = 0.75, deadbeats: int = 0) -> numpy.ndarray:
> 	...

decode_morse_to_string^

Decodes morse dots and dashes to plaintext. Returns a string

def decode_morse_to_string(morse: str, char_sep: str = ' ', word_sep: str = '  ', replace_on_unknown: str | bool = '?') -> str:
> 	...

make_morse_visual_from_beats^

Converts a beats list to a visual representation in string form using block chars (unicode char 2588). Returns a string

def make_morse_visual_from_beats(beats: list) -> str:
> 	...

play_morse^

Converts dots and dashes to a waveform and plays it on system speakers. Returns None

def play_morse(morse: bytes, tone: int = 1000, words_per_minute: int = 24, sample_rate: int = 32000, verbose: bool = True) -> None:
> 	...

play_string^

Converts plaintext to a waveform and play it on system speakers. Returns None

def play_string(in_str: bytes, tone: int = 1000, words_per_minute: int = 24, sample_rate: int = 32000, verbose: bool = True) -> None:
> 	...

play_waveform^

Plays a waveform. Return None

def play_waveform(waveform: bytes, format=1, sample_rate=32000) -> None:
> 	...

Changelog^

0.0.0^

Create Project

0.0.1^

Fix main module not being included in pip module.

Generated with py_simple_readme

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

py_simple_morse_code-0.0.2.tar.gz (52.2 kB view hashes)

Uploaded Source

Built Distribution

py_simple_morse_code-0.0.2-py3-none-any.whl (40.8 kB view hashes)

Uploaded Python 3

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