A python module for interacting with morse code
Project description
py_simple_morse_code 0.0.0
About^
A python module for interacting with 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
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
Built Distribution
Hashes for py_simple_morse_code-0.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9f6acc76131f769ff4f712ed452409c570057cb38549067e45e5ca2fddfa5a2 |
|
MD5 | bc01ff81f96bbf6f2718a67f337a62f2 |
|
BLAKE2b-256 | 68ced839a4cf769861869fde3e4bed92f03afdc7868dd50b7e23c15a3f55f9a6 |
Hashes for py_simple_morse_code-0.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6cfba160565d64343d70ee431f310a8c2e6fa4ac0d21fb58ef0b1b64667f149 |
|
MD5 | 5b7be0fa256251b7c2b5ae1eee4e46cf |
|
BLAKE2b-256 | 9bdd3ce3f2c9420b541777db55ec16e4141dec9730cbad1f62c98c340becea9b |