-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (26 loc) · 728 Bytes
/
main.py
File metadata and controls
31 lines (26 loc) · 728 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from morse import *
import os
import importlib
packages = ['numpy', 'simpleaudio']
def check_required_packages(packages):
missing = []
for pkg in packages:
try:
importlib.import_module(pkg)
except ImportError:
missing.append(pkg)
if missing:
print(f"Missing packages: {', '.join(missing)}")
return False
return True
def cls():
os.system('cls' if os.name=='nt' else 'clear')
def main_menu():
cls()
check_required_packages(packages)
morse = MorsePlayer(wpm=20, tone=600)
text = input("Enter text to convert to Morse: ")
print("Converted => " + morse.to_morse(text))
morse.play(text)
if __name__ == "__main__":
main_menu()