-
Notifications
You must be signed in to change notification settings - Fork 4
/
AI_Model.py
237 lines (117 loc) · 3.89 KB
/
AI_Model.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
232
233
234
235
236
237
import webbrowser
from speech_recognition import Microphone, Recognizer, AudioFile, UnknownValueError, RequestError
from neuralintents import GenericAssistant
import Carbon_Value
import Events
import Google_Answers
import Human_Names
import Humidity
import IMDB
import Image_Search
import Jokes
import Launching_AI
import Movies
import News
import Power_Consuptions
import Screen_Shot
import Soil_Moisture
import Switchs
import Temperature
import Water_Lv
import Weather
import Wikipedia_Find
import Wishes
import Youtube_Py
import music
import Google
import Speak
import datetime
import Send_Weather
import Send_News
import Identification_Name
import Math_Slover
from Dictionary import Dictionary
text: str = ''
def time_now():
strTime = datetime.datetime.now().strftime('%I:%M %p')
Speak.Speak(f"Sir, the time is {strTime}")
def quick_answer():
Google_Answers.google_answers(text)
def insta():
name = Human_Names.name_recognizer(text)
if name == 'none':
base_url = "https://www.instagram.com"
else:
base_url = "https://www.instagram.com/"+name+"/"
base_url = base_url.replace(" ", "")
webbrowser.open(base_url, new=2)
def direct_ToDictionary():
Dictionary.Dictionary(text)
def voice_Text():
recognition = Recognizer()
mic = Microphone()
with mic:
recognition.adjust_for_ambient_noise(mic, duration=0.2)
print("Talk")
audio = recognition.record(mic, 5)
try:
recognized = recognition.recognize_google(audio)
print('You Said : ', recognized)
return recognized
except UnknownValueError:
print('Unable to Recognize audio')
return 'None'
except RequestError as error:
print('Error Detected : ', error)
return 'None'
return recognized
mappings = {'weather': Weather.get_Weather,
'screenshot': Screen_Shot.screen_shot,
'music': music.music_picker,
'google': Google.search_it,
'time': time_now,
'news': News.get_news,
'wikipedia': Wikipedia_Find.wiki,
'youtube': Youtube_Py.py_youtube,
'on_sprinkler': Switchs.sprinkler_on,
'off_sprinkler': Switchs.sprinkler_off,
'on_pump': Switchs.Water_on,
'off_pump': Switchs.Water_off,
'send_news': Send_News.send_news,
'send_weather': Send_Weather.get_Weather,
'humidity': Humidity.get_humidity,
'temperature': Temperature.get_temperature,
'carbon': Carbon_Value.get_CarbonValue,
'events': Events.get_event,
'my_name': Identification_Name.name_operations,
'math': Math_Slover.Running_Math,
'instagram': insta,
'IMDB': IMDB.talk,
'power': Power_Consuptions.battery_data,
'joke': Jokes.joke_function,
'convert': quick_answer,
'distance': quick_answer,
'google_question': quick_answer,
'drugs': quick_answer,
'new_movies': Movies.list_movies,
'Dictionary': direct_ToDictionary,
'knockout': Wishes.Knock,
'wishes_GoodMorning': Wishes.Good_Morning,
'wishes_GoodEvening': Wishes.Good_Evening,
'wishes_GoodAfternoon': Wishes.Good_Afternoon,
'thanks': Wishes.you_areWelcome,
'bye': Wishes.bye_bye,
'soil_moisture': Soil_Moisture.get_SoilMoist,
'Water_Level': Water_Lv.get_WaterLv,
'who_are': Wishes.who_am_i,
'greeting': Wishes.Hey_user
}
Assistant = GenericAssistant('intents.json', intent_methods=mappings)
# Assistant.train_model()
# Assistant.save_model()
Assistant.load_model()
print("Pre Build Model Loaded")
Launching_AI.wishMe()
while True:
text = voice_Text()
Assistant.request(text)