Package: py-simple-morse-code
py_simple_morse_code 0.0.5AboutInstallationRequirementsGUI UsageModule UsageClassesSignalProcessorMorseCodeTranslatorFunctionsencode_string_to_morseencode_string_to_beatsencode_string_to_waveformencode_morse_to_beatsencode_morse_to_waveformencode_beats_to_waveformdecode_morse_to_stringmake_morse_visual_from_beatsplay_morseplay_stringplay_waveformChangelog0.0.50.0.40.0.30.0.20.0.10.0.0About^A python module for interacting with morse code with live decoding feature.Live Decoder In Action:https://raw.githubusercontent.com/AndrewSpangler/py_simple_morse_code/main/docu/live_decoder.mp4Installation^Run`pipinstallpy_simple_morse_code`Requirements^pyaudioscipynumpyGUI Usage^To launch the gui, install via pip and runpython -m py_simple_morse_codeModule Usage^frompy_simple_morse_codeimportSignalProcessor,MorseCodeTranslatorsignal_processor=SignalProcessor(mic_index=0,min_tone=800,max_tone=1200)decoder=MorseCodeTranslator(words_per_minute=10)last_content=""try:signal_processor.start_session()print("Begin processing")whileTrue:decoder.update(signal_processor.process())ifnotdecoder.parsed_content==last_content:last_content=decoder.parsed_contentprint(last_content)exceptExceptionase:print("End processing")signal_processor.end_session()raiseeClasses^SignalProcessor^Non-blocking CW signal processor. The .process() method returns true if a CW tone was found in the signal.classSignalProcessor(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):...defend_session(self)->None:"""Ends the audio stream. *Returns None*"""defprocess(self)->bool:"""Process a chunk of the audio stream from the buffer. *Returns None*"""defstart_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.classMorseCodeTranslator(object):def__init__(self,words_per_minute:int=24,debounce_time:float=0.01,tolerance:int=0):...defupdate(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 stringdefencode_string_to_morse(in_str:str,short_char:str='.',long_char:str='-',sep_char:str=' ',replace_on_unknown:str='?',verbose:bool=True)->str:>...encode_string_to_beats^Converts a plaintext string to a beats list.Returns a list of boolsdefencode_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 arraydefencode_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 boolsdefencode_morse_to_beats(morse:str,verbose:bool=True)->list:>...encode_morse_to_waveform^Encode a morse string to a waveform.Returns a float32 1-dimensional numpy arraydefencode_morse_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 arraydefencode_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 stringdefdecode_morse_to_string(morse:str,char_sep:str=' ',word_sep:str='  ',replace_on_unknown: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 stringdefmake_morse_visual_from_beats(beats:list)->str:>...play_morse^Converts dots and dashes to a waveform and plays it on system speakers.Returns Nonedefplay_morse(morse:str,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 Nonedefplay_string(in_str:str,tone:int=1000,words_per_minute:int=24,sample_rate:int=32000,verbose:bool=True)->None:>...play_waveform^Plays a waveform.Return Nonedefplay_waveform(waveform:bytes,format=1,sample_rate=32000)->None:>...Changelog^0.0.5^Make module more widely compatible by removing newer syntax.0.0.4^Fix PyPi page links0.0.3^Add example usage and images to readme and clean up typehints0.0.2^Movemainmodule to src/py_simple_morse_code/main.py0.0.1^Fixmainmodule not being included in pip module.0.0.0^Create ProjectGenerated withpy_simple_readme