-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
26 lines (19 loc) · 679 Bytes
/
main.py
File metadata and controls
26 lines (19 loc) · 679 Bytes
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
import requests
import json
import gtts
import playsound
city = input("enter the name of the city\n")
url = f"https://api.weatherapi.com/v1/current.json?key=78737490e93a4a31b9b155845231307&q={city}"
r = requests.get(url)
#print (r.text)
wdict = json.loads(r.text)
var = {wdict["current"]["temp_c"]}
var1 = {wdict["current"]["temp_f"]}
text = f"the current weather in {city} is {var} "
sound = gtts.gTTS(text, lang ="en")
sound.save("welcome.mp3")
playsound.playsound("welcome.mp3")
# print(f"the wheter in celsicus is :{var}C")
# # print(wdict["current"]["temp_c"])
# print(f"the wheter in fer is :{var1}F")
# # print(wdict["current"]["temp_f"])