starting ada stuff
This commit is contained in:
parent
b4fff86a37
commit
acdf83da5a
|
@ -0,0 +1 @@
|
|||
Beginning Ada Programming
|
|
@ -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;
|
||||
|
|
@ -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()
|
|
@ -0,0 +1 @@
|
|||
pyttsx3
|
Loading…
Reference in New Issue