From acdf83da5a4bb7b2600a2d43e57a04eed303a687 Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Fri, 21 Oct 2022 19:18:42 -0700 Subject: [PATCH] starting ada stuff --- ada/bap/README | 1 + ada/bap/chapter01/hello/hello_world.adb | 9 ++++ misc/ns/keypad.py | 62 +++++++++++++++++++++++++ misc/ns/requirements.txt | 1 + 4 files changed, 73 insertions(+) create mode 100644 ada/bap/README create mode 100644 ada/bap/chapter01/hello/hello_world.adb create mode 100755 misc/ns/keypad.py create mode 100755 misc/ns/requirements.txt diff --git a/ada/bap/README b/ada/bap/README new file mode 100644 index 0000000..ccdddf1 --- /dev/null +++ b/ada/bap/README @@ -0,0 +1 @@ +Beginning Ada Programming diff --git a/ada/bap/chapter01/hello/hello_world.adb b/ada/bap/chapter01/hello/hello_world.adb new file mode 100644 index 0000000..79e9f7c --- /dev/null +++ b/ada/bap/chapter01/hello/hello_world.adb @@ -0,0 +1,9 @@ +with Ada.Text_IO; + +procedure hello_world is +begin + Ada.Text_IO.Put_Line("Hello, world."); + Ada.Text_IO.Put("Now, goodbye."); + Ada.Text_IO.New_Line; +end hello_world; + diff --git a/misc/ns/keypad.py b/misc/ns/keypad.py new file mode 100755 index 0000000..45306f4 --- /dev/null +++ b/misc/ns/keypad.py @@ -0,0 +1,62 @@ +import pyttsx3 + +engine = pyttsx3.init() +engine.setProperty("rate", 100) + +keys = { + "2": "abc", + "3": "def", + "4": "ghi", + "5": "jkl", + "6": "mno", + "7": "pqrs", + "8": "tuv", + "9": "wxyz", + "0": " ", +} + +numbers_spoken = [ + "zero", + "one", + "two", + "three", + "four", + "five", + "six", + "seven", + "eight", + "nine", +] + + +def keypad_encode(text): + orig_message = text.lower() + + keypad_strokes = [] + for i in orig_message: + strokes = _to_stroke(i) + if strokes: + keypad_strokes.append(strokes) + coded = " ".join(keypad_strokes) + coded_ns = coded.replace(" ", "") + coded_arr = list(coded_ns) + numbers = [] + + for x in coded_arr: + numbers.append(numbers_spoken[int(x)]) + return numbers + + +def _to_stroke(char): + for i in keys: + if char in keys[i]: + return i * (keys[i].find(char) + 1) + return None + + +def transmit(msg): + emsg = keypad_encode(msg) + print(emsg) + for number in emsg: + engine.say(number) + engine.runAndWait() diff --git a/misc/ns/requirements.txt b/misc/ns/requirements.txt new file mode 100755 index 0000000..1018425 --- /dev/null +++ b/misc/ns/requirements.txt @@ -0,0 +1 @@ +pyttsx3