-
Notifications
You must be signed in to change notification settings - Fork 4
/
Main.py
239 lines (120 loc) · 4.45 KB
/
Main.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import os
from flask import *
import webbrowser
import pywhatkit
import wikipedia
import Carbon_Value
import Events
import Humidity
import News
import Request_web
import Screen_Shot
import Send_News
import Send_Weather
import Speak
import datetime
import speech_recognition as sr
import Temperature
import Weather
import Wishes
import music
app = Flask(__name__, template_folder='template')
text: str = 'User Said'
text2: str = 'HELLOSxxxxxxxxxxxxxxxxxxxx'
@app.route('/')
def home():
return render_template('index.html', n1=text, n2=text2)
def wishMe():
hour = int(datetime.datetime.now().hour)
if 0 <= hour < 12:
Speak.Speak("Good Morning!")
text = "Good Morning!"
elif 12 <= hour < 18:
Speak.Speak("Good Afternoon!")
text = "Good Afternoon"
else:
Speak.Speak("Good Evening!")
text = "Good Evening"
Speak.Speak("I am FRIDAY. . Please tell me , how Can I help you")
def takeCommand():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognizing...")
command = r.recognize_google(audio, language='en-in')
print(f"User said: {command}\n")
except Exception as e:
print("Say that again please...")
return "None"
return command
if __name__ == "__main__":
app.run(debug=True, host='127.0.0.1', port=8080)
wishMe()
while True:
query = takeCommand().lower()
if 'hay' in query:
Speak.Speak('Hey How Are You? How Can I Help You')
elif 'hello friday' in query:
Speak.Speak('Your Friday here, So tell me what can i do for you')
elif 'good morning' in query:
Wishes.wish_toFriday()
elif 'wikipedia' in query:
Speak.Speak('Searching Wikipedia...')
query = query.replace("wikipedia", "")
try:
results = wikipedia.summary(query, sentences=10)
Speak.Speak("According to Wikipedia")
Speak.Speak(results)
except Exception as e:
Speak.Speak("Results Not Found")
elif 'send' in query:
Send_News.send_news()
elif 'news' in query:
News.get_news()
elif 'events' in query:
Events.event()
elif 'search for' in query:
query = query.replace('search for', '')
pywhatkit.search(query)
elif 'play' in query:
query = query.replace('play', '')
Speak.Speak(query + 'Play soon enjoy music')
pywhatkit.playonyt(query)
elif 'quick shot' in query:
Speak.Speak('Wait Five Seconds For ScreenShot capture')
Screen_Shot.screen_shot()
elif 'sing' in query:
music.music_picker()
elif 'the time' in query:
strTime = datetime.datetime.now().strftime('%I:%M %p')
Speak.Speak(f"Sir, the time is {strTime}")
elif 'weather report' in query:
Speak.Speak("Please wait I working on it")
Send_Weather.get_Weather()
elif 'weather' in query:
Speak.Speak("Please wait for get weather details")
Weather.get_Weather()
elif 'temperature' in query:
Temperature.event()
elif 'carbon value' in query:
Carbon_Value.event()
elif 'humidity' in query:
Humidity.event();
elif 'turn on pump' in query:
Speak.Speak('Water Pump Will turn on')
Request_web.web_requests('http://192.168.43.178/1/on', 'Water Pump turn on successfully')
elif 'turn off pump' in query:
Speak.Speak('Water Pump Will turn off')
Request_web.web_requests('http://192.168.43.178/1/off', 'Water Pump turn off successfully')
elif 'turn on sprinkler' in query:
Speak.Speak('sprinkler Will turn on')
Request_web.web_requests('http://192.168.43.178/2/on', 'sprinkler turn on successfully')
elif 'turn off sprinkler' in query:
Speak.Speak('sprinkler Will turn off')
Request_web.web_requests('http://192.168.43.178/2/off', 'sprinkler turn off successfully')
elif 'close chrome' in query:
os.system("taskkill /im chrome.exe /f")
Speak.Speak('As Your Wish Sir, Chrome Google was close immediately')