-
Notifications
You must be signed in to change notification settings - Fork 1
/
simha.py
183 lines (141 loc) · 6.06 KB
/
simha.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
import pyttsx3
import sys, os
import datetime
import time
import command
#import ConfigParser
import speech_recognition as sr
import wikipedia
import webbrowser
import smtplib
#for getting news
import bs4
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen
#for getting wether report
import requests, json
import pyaudio
#err = Pa_Initialize();
from weather import Weather, Unit
import chat1
import jock
import mail1
import re
import birthday
import wish
import googleSearch
if __name__=="__main__":
wish.wishMe()
answer='yes'
while answer == 'yes':
command.speak("Please , Tell me what can I do ?")
query = command.takeCommand().lower()
if 'talk' in query:
command.speak("Ok boss , its seems like you have a free time I am ready")
chat1.chatty()
elif 'birthday' in query:
birthday.handle()
elif 'bye' in query:
command.speak("by boss , come back again . i will be there for sure")
elif 'what can you do' in query:
command.speak("I can do , whatever which you taught me")
elif 'news' in query:
news_url="https://news.google.com/news/rss"
Client=urlopen(news_url)
xml_page=Client.read()
Client.close()
soup_page=soup(xml_page,"xml")
news_list=soup_page.findAll("item")
speak('now ,I will read news for you boss , please listen it carefully,,')
for news in news_list[0:4]:
command.speak(news.title.text)
elif ' weather report' in query:
pi_key = "Your_API_Key"
base_url = "http://api.openweathermap.org/data/2.5/weather?"
command.speak("boss tell me city name")
city_name = command.takeCommand().lower()
complete_url = base_url + "appid=" + pi_key + "&q=" + city_name
response = requests.get(complete_url)
x = response.json()
if x["cod"] != "404":
y = x["main"]
current_temperature = y["temp"]
current_pressure = y["pressure"]
current_humidiy = y["humidity"]
z = x["weather"]
weather_description = z[0]["description"]
speak(f'current tempreture is {current_tempreture}')
speak(f'current pressure is {current_pressure}')
speak(f'current humidity is {current_humidity}')
elif 'wikipedia' in query :
command.speak("Searching wikipedia boss ,wait a second")
query =query.replace("wikipedia",'')
results=wikipedia.summary(query,sentences=2)
command.speak("According to Wikipedia")
print(results)
command.speak(results)
elif "open youtube" in query:
command.speak("openning you tube Boss, Wait a second and it will there for entertainment")
webbrowser.open("youtube.com")
time.sleep(3)
elif 'open google' in query:
command.speak("openning Google Boss, Wait a second")
webbrowser.open("google.com")
elif 'open facebook' in query:
command.speak("openning Facebook Boss ,Wait a second")
webbrowser.open("facebook.com")
time.sleep(3)
elif 'play music' in query:
command.speak("playing your Favorite song Boss, Wait a second")
music_dir ='E:\\Hindi\\00 3 Idiots'
songs=os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir,songs[2]))
elif 'the time' in query:
strTime=datetime.datetime.now().strftime("%H:%M:%S")
command.speak(f"Sir ,the time is {strTime}")
elif 'email' in query:
try:
mail1.mail2()
except Exception as e:
print(e)
command.speak("sorry friend email cants send")
elif 'define yourself ' in query:
command.speak("YOu want to know about me , I like it . I am Simhha ,. Personal Assistant of Dnyanesh . i devolped by my boss as part of his study . my date of birth 27 july 2019 . i am getting new features ")
elif 'instagram' in query:
webbrowser.open("instagram.com")
elif 'open file' in query:
command.speak("ok boss , which file you want to open")
content=command.takeCommand()
try:
path="E:/"+content
path=os.path.realpath(path)
os.startfile(path)
except Exception :
command.speak("file not Found boss , sorry")
elif 'joke' in query:
jock.jock1()
elif 'finance' in query:
command.speak("boss , i getting todays Finance update for you , look at your screen")
webbrowser.open("www.google.com/finance")
command.speak("how much time you want to stay on this Finance site boss")
tt=takeCommand()
command.speak("ok boss , i will remind you after time over")
time.sleep(4)
#time.sleep(int(re.search(r'\d+', tt).group()))
command.speak("time over boss , come back . ")
elif 'close' in query:
webbrowser.close()
elif 'map' in query:
webbrowser.open("https://www.google.com/maps/@18.4699367,73.8213773,14z")
elif 'search' in query:
googleSearch.opening()
elif 'hear' in query:
command.speak("yes bosssss , i am there, for sure, always ")
else:
command.speak("command not understood boss")
answer='no'
command.speak("you want to continue boss")
answer=command.takeCommand().lower()
if 'no' in answer :
command.speak("Ok boss , see you Again , bye")