-
Notifications
You must be signed in to change notification settings - Fork 4
/
Marsh.py
58 lines (44 loc) · 1.22 KB
/
Marsh.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
import speech_recognition as sr
from Brain.MarshBrain import ReplyBrain
from Body.Speak import Speak
print(">>> Starting Marsh.... Please wait for few seconds. ")
from Body.Listen import MicExecution
print(">>> MarshAI is Getting Ready....")
from Main import MainTaskExecution
def MainExecution():
Speak("Hello Sir")
Speak(" What can i do for you?")
while True:
Data = MicExecution()
Data= str(Data)
ValueReturn = MainTaskExecution(Data)
if ValueReturn== True:
pass
elif len(Data)<3:
pass
else:
Reply= ReplyBrain(Data)
Speak(Reply)
def Listen():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening.....")
r.pause_threshold = 1
audio = r.listen(source,0,8)
try :
print("Recognizing...")
query = r.recognize_google(audio, language ="en")
except:
return ""
query = str(query).lower()
print(query)
return query
def Wakeupdetected():
queery= Listen().lower()
if "wake up" in queery :
print(">>> Wake up detected >>>")
MainExecution()
else:
pass
while True:
Wakeupdetected()