-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathspeak.py
More file actions
63 lines (46 loc) · 1.22 KB
/
speak.py
File metadata and controls
63 lines (46 loc) · 1.22 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import os
import record
import transcribe
import keyboard
import stt
import time
import evaluate
SAVE_FILE = "output.wav"
simple_rules = {
"declare":["variable","list","class","function"],
"control":["if", "for", "while"]
}
declared = []
time.sleep(2)
while True:
print "recording"
# stt.listen_for_speech(SAVE_FILE)
record.record_and_save(SAVE_FILE)
print "transcribing"
trans = transcribe.audio_to_text(SAVE_FILE)
if trans == None:
print "No text found"
continue
print "saving"
print "text understood:" + trans + '\n'
os.remove(SAVE_FILE)
text = evaluate.evaluate(trans)
"""
words = trans.split(' ')
text = ''
if words[0] == "declare":
if words[1] in simple_rules["declare"]:
if words[1] == "variable":
text += (words[2].lower() + ' = ' + '"' + words[4]) + '"'
# elif words[0] == "control":
#
elif words[0] == "print":
text = "print "
for r in words[1:]:
text += r
elif words[0] == "hello":
keyboard.new_line()
else:
print "Didn't get that please try again"
continue """
keyboard.write_text(text)