-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkprojectmini.py
161 lines (123 loc) · 3.88 KB
/
kprojectmini.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# This Project helps user use system without physically touching it ratherthan use system with hand gesture and speech recognition.
import re
import cv2
from cvzone.HandTrackingModule import HandDetector
from pyautogui import press,typewrite,hotkey,click
import speech_recognition as sr
from time import sleep
from os import system
def audiorec():
print("Hello Krishna I am Listening")
r = sr.Recognizer()
# listening the speech and store in audio_text variable
while True:
with sr.Microphone() as source:
audio_text = r.listen(source)
try:
SPtotext = r.recognize_google(audio_text)
except:
print("Sorry, I did not get that")
continue
Aakash = str(SPtotext)
Ranjan = Aakash.lower()
print(SPtotext)
if Ranjan == "useless":
break
return Ranjan
#
# spotify
def spotify():
command = "start spotify"
system(command)
sleep(2)
press('Space')
# notepad
def notepad():
system('subl')
sleep(1)
hotkey('ctrl','n')
print("Hello Krishna I am Listening")
r = sr.Recognizer()
# listening the speech and store in audio_text variable
while True:
with sr.Microphone() as source:
audio_text = r.listen(source)
try:
SPtotext = r.recognize_google(audio_text)
print(SPtotext)
except:
print("Sorry, I did not get that")
continue
Aakash = str(SPtotext)
REC_TEXT = Aakash.lower()
if REC_TEXT == 'line change':
press('enter')
elif REC_TEXT == "save it":
hotkey('ctrl','s')
sleep(0.5)
press('enter')
sleep(0.5)
hotkey('alt','f4')
break
elif REC_TEXT == "useless":
break
else:
typewrite(SPtotext,interval=0.05)
# if REC_TEXT == "useless":
# break
# Whatsapp
def callwhat():
press('win')
sleep(0.5)
typewrite('whatsapp')
sleep(0.5)
press('enter')
sleep(7)
hotkey('win', 'up')
press('tab',presses=4,interval=0.05)
sleep(0.5)
typewrite('Prasnjit')
# audi = audiorec()
# aa.typewrite(audi)
press('enter') # implementation of call is pending and message
click(1725,62)
sleep(3)
click()
sleep(0.5)
cap = cv2.VideoCapture(0)
cap.set(3, 640)
cap.set(4, 480)
detector = HandDetector(detectionCon=0.8, maxHands=1)
# detector = HandDetector(detectionCon=0.7, maxHands=1)
while cap.isOpened():
success, in_img = cap.read()
img = cv2.flip(in_img, 1)
img = detector.findHands(img)
lmList, bboxInfo = detector.findPosition(img)
if len(lmList) != 0:
# for id, lm in enumerate(lmList):
fingers = detector.fingersUp()
# for spotify 1 2
if fingers[0] == False and fingers[1] == True and fingers[2] ==True and fingers[3] == False and fingers[4] == False:
spotify()
for j in range(10000):
continue
print(fingers)
# for Whatsapp
if fingers[0] == False and fingers[1] == True and fingers[2] == True and fingers[3] == True and fingers[4] == True:
callwhat()
for j in range(10000):
continue
print(fingers)
# for notepad 0 0 0 0 0
if fingers[0] == False and fingers[1] == False and fingers[2] == False and fingers[3] == False and fingers[4] == False:
notepad()
for j in range(10000):
continue
cv2.imshow("Video-Feed", img)
if cv2.waitKey(1) == ord("q"):
break
cap.release()
cv2.destroyAllWindows()
# cvzone==1.4.1
# mediapipe==0.8.7