-
Notifications
You must be signed in to change notification settings - Fork 0
/
mod.py
127 lines (69 loc) · 2.38 KB
/
mod.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
import re
import urllib.request
import speech_recognition as sr
import os
import vlc
import requests
def listener():
r = sr.Recognizer()
with sr.Microphone() as source:
print("listening...")
audio = r.listen(source) # listen for the first phrase and extract it into audio data
print("understanding...")
command = r.recognize_google(audio).lower()
return command
def weather(location):
location=location.title()
if location == "":
exit
else:
try:
city = location.replace(" ", "-")
url = "https://www.weather-forecast.com/locations/"+city+"/forecasts/latest"
data = urllib.request.urlopen(url).read()
data1 = data.decode("utf-8")
m = re.search('span class="phrase">', data1)
start = m.end()
end = start + 300
newString = data1[start:end]
x = re.search("</span>", newString)
end = x.start()
final = newString[0:end]
final=final.replace("°C", " Degrees Celsius")
return final
except:
return "The city doesn't exist"
#########Functions TO DO LIST:
def stream_music():
p = vlc.MediaPlayer('C:\\Users\\Koolkid\\Downloads\\Music\\Pink - Just Give Me A Reason.mp3')#("http://s1.mmdl.xyz/1396/09/22/Eminem%20-%20Revival%20(320)/15.%20Offended.mp3")
p.play()
def scores(sports):
""" sports code goes here"""
pass
def news_headlines(country):
""" news code goes here"""
pass
def take_notes():
"""notes code goes here"""
pass
def hide_show(task):
if task == "hide":
return wm_state('iconic')
if task == "show":
return wm_state('normal')
def get_definition(word):
print("looking up: "+word)
try:
url = "https://www.merriam-webster.com/dictionary/"+word
r = requests.get(url)
data1 = r.text
m = re.search('<meta name="description" content="', data1)
start = m.end()
end = start + 300
newString = data1[start:end]
x = re.search('How to', newString)
end = x.start()
define = newString[0:end]
return define
except:
return "The word doesn't exist"