-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Source code Vc world time zone
108 lines (91 loc) · 4 KB
/
Source code Vc world time zone
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
import speech_recognition as sr
import pyttsx3
from bs4 import BeautifulSoup
import requests
from datetime import datetime
import pytz
listener = sr.Recognizer()
engine = pyttsx3.init()
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[1].id)
blessey = 0
def talk(text):
engine.say(text)
engine.runAndWait()
if blessey == 0:
talk('hello iam angel Weather app voice assistant')
talk('My devloper Codecrusher KARAN')
print('hello iam angel Weather app voice assistant')
talk('what can i do for you people')
print('what can i do for you people')
else:
print('cant get it')
def take_command():
try:
with sr.Microphone() as source:
print('listening.......')
talk('listening...')
voice = listener.listen(source)
command = listener.recognize_google(voice)
command = command.lower()
if 'Angel' in command:
command = command.replace('blessy', '')
print(command)
except:
pass
return command
def run_blessy():
command = take_command()
print(command)
if 'weather' in command:
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'}
def weather(city):
city = city.replace(" ", "+")
res = requests.get(
f'https://www.google.com/search?q={city}&oq={city}&aqs=chrome.0.35i39l2j0l4j46j69i60.6128j1j7&sourceid=chrome&ie=UTF-8',
headers=headers)
print("Searching...\n")
talk("Searching...\n")
soup = BeautifulSoup(res.text, 'html.parser')
location = soup.select('#wob_loc')[0].getText().strip()
time = soup.select('#wob_dts')[0].getText().strip()
info = soup.select('#wob_dc')[0].getText().strip()
weather = soup.select('#wob_tm')[0].getText().strip()
print(location)
talk(location)
print(info)
talk(info)
print(time)
talk(time)
ab = (weather + "°C")
talk(ab)
print(ab)
city1 = "coimbatore"
talk(city1)
city = city1 + " weather"
weather(city)
abc = ("Have a fabulous day people")
talk(abc)
print(abc)
elif 'world time' in command:
Country_Zones = ['America/New_York', 'Asia/Kolkata', 'Australia/Sydney',
'Canada/Atlantic', 'Brazil/East', 'Chile/EasterIsland', 'Cuba', 'Egypt',
'Europe/Amsterdam', 'Europe/Athens', 'Europe/Berlin', 'Europe/Istanbul',
'Europe/Jersey', 'Europe/London', 'Europe/Moscow', 'Europe/Paris',
'Europe/Rome', 'Hongkong', 'Iceland', 'Indian/Maldives', 'Iran',
'Israel', 'Japan', 'NZ', 'US/Alaska', 'US/Arizona', 'US/Central',
'US/East-Indiana']
country_time_zones = []
for country_time_zone in Country_Zones:
country_time_zones.append(pytz.timezone(country_time_zone))
for i in range(len(country_time_zones)):
country_time = datetime.now(country_time_zones[i])
print(f"The date of {Country_Zones[i]} is {country_time.strftime('%d-%m-%y')} and The time of {Country_Zones[i]} is {country_time.strftime('%H:%M:%S')}")
talk(f"The date of {Country_Zones[i]} is {country_time.strftime('%d-%m-%y')} and The time of {Country_Zones[i]} is {country_time.strftime('%H:%M:%S')}")
elif 'thank you' in command:
talk('Thank you for using me gentleman or Wommen!!!!, if you need any other information related news,to make call,whatsapp msgs or to know about location kindly contact my parent Voice Assistance')
else:
talk('cant get it....please say it again')
while True:
run_blessy()