-
Notifications
You must be signed in to change notification settings - Fork 1
/
manualSpeech.py
40 lines (34 loc) · 927 Bytes
/
manualSpeech.py
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
32
33
34
35
36
37
38
39
40
import Tkinter as tk
import subprocess
import time
def execute_unix(inputcommand):
p = subprocess.Popen(inputcommand, stdout=subprocess.PIPE, shell=True)
(output, err) = p.communicate()
return output
root = tk.Tk()
with open('/var/www/newfile1.txt') as f:
content = f.readlines()
line = content[0]
contentArray = line.split(';')
list = contentArray
contentArray = line.split(',')
list2 = {}
key_list=[]
for i in contentArray:
dummy_list = i.split(':')
list2.update({dummy_list[0]:dummy_list[1]})
for k,v in list2.items():
key_list.append(k)
def onKeyPress(event):
if event.char in key_list:
print (list2[event.char])
c = 'espeak -k20 -s90 -a150 -p60 "%s" 2>/dev/null'% list2[event.char]
execute_unix(c)
time.sleep(2)
else:
print('enter a valid key')
root.geometry('300x200')
text = tk.Text(root, font=('Comic Sans MS', 40))
text.pack()
root.bind('<KeyRelease>', onKeyPress)
root.mainloop()