-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDetection.py
37 lines (30 loc) · 1023 Bytes
/
Detection.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
import os
import speech_recognition as sr
import keyboard
from Body.cli_design import design_Detection
design_Detection()
def takeCommand():
# It takes microphone input from the user and returns string output
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 0.8
r.energy_threshold = 100
audio = r.listen(source, 0, 3)
try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"User said: {query}\n")
except:
print("Say that again please...")
return "None"
return query.lower()
while True:
wake_up=takeCommand()
if 'wakeup' in wake_up or 'wake up' in wake_up:
os.startfile(f'{os.getcwd()}\main.py')
exit()
if 'rewoke' in wake_up or 'revoke' in wake_up or 'reebook' in wake_up or 'rebook' in wake_up or 'reebok' in wake_up:
keyboard.press('space')
os.startfile(f'{os.getcwd()}\main.py')
exit()