-
Notifications
You must be signed in to change notification settings - Fork 0
/
voicef22.py
88 lines (67 loc) · 1.92 KB
/
voicef22.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import speech_recognition as sr
import os
import pyautogui
import time
text = "nothing"
i=0
while i!=1:
r = sr.Recognizer()
with sr.Microphone() as source:
print("Speak :")
audio = r.listen(source)
try:
text=r.recognize_google(audio)
except:
print("could not recognize your voice")
#break
if text =="backspace":
pyautogui.press("backspace")
print("backspace")
if text == "down":
pyautogui.keyDown("up")
time.sleep(3)
pyautogui.keyUp("up")
if text == "fly":
pyautogui.keyDown("down")
time.sleep(3)
pyautogui.keyUp("down")
if text == "left":
pyautogui.keyDown("left")
time.sleep(6)
pyautogui.keyUp("left")
if text == "right":
pyautogui.keyDown("right")
time.sleep(6)
pyautogui.keyUp("right")
if text == "shopping":
print("crazy")
pyautogui.keyDown("right")
time.sleep(1)
pyautogui.keyDown("left")
time.sleep(1)
pyautogui.keyDown("right")
time.sleep(1)
pyautogui.keyDown("left")
time.sleep(1)
pyautogui.keyDown("right")
time.sleep(1)
pyautogui.keyDown("left")
time.sleep(1)
break
if text == "land":
pyautogui.typewrite(["A"])
pyautogui.typewrite(["7"])
if text == "level":
pyautogui.typewrite(["L"])
if text == "shop":
pyautogui.typewrite(["spacebar"])
if text == "gun":
pyautogui.typewrite(["2"])
if text == "missile":
pyautogui.typewrite(["3"])
if text == "ground":
pyautogui.typewrite(["4"])
if text == "bomb":
pyautogui.typewrite(["5"])
if text == "bail":
pyautogui.hotkey("ctrl","E")