-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfridayfunctions.py
More file actions
96 lines (75 loc) · 2.65 KB
/
fridayfunctions.py
File metadata and controls
96 lines (75 loc) · 2.65 KB
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
import wikipedia
import webbrowser
import random
import os
import datetime
import time
import subprocess
import speakandrecognizefunctions as SRF
USER = "sumesh"
def wishme():
hour = int(datetime.datetime.now().hour)
if hour >= 0 and hour <= 12:
SRF.speak("good morning! " + USER)
elif hour >= 12 and hour < 18:
SRF.speak("good aftenoon! " + USER)
else:
SRF.speak("good evening! " + USER)
def note(text):
date = datetime.datetime.now()
filename = str(date).replace(":", "-")+"-note.txt"
try:
os.mkdir("notes_folder")
except FileExistsError:
pass
completename = os.path.join("notes_folder", filename)
with open(completename, "w") as f:
f.write(text)
f.close()
subprocess.Popen(["notepad.exe", completename])
def wikipediasearch(query):
try:
#SRF.speak("What do you want to search for ?")
#wikiquery = SRF.takecommand()
query = query.replace("wikipedia", "")
query = query.replace("search", "")
query = query.replace(" on ", "")
wikiquery = query.replace("for", "")
SRF.speak('searching wikipedia.....')
print("this is the wikipedia query :" + wikiquery)
results = wikipedia.summary(wikiquery, sentences=2)
time.sleep(2)
SRF.speak("according to wikipedia")
print(results)
SRF.speak(results)
except:
SRF.speak("i did not get that !!")
def open_programs_websites(query):
#chrome_path = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe %s"
query = query.replace("open ", "")
if "youtube" in query:
SRF.speak("opening youtube")
#webbrowser.get(chrome_path). open_new_tab("youtube.com")
webbrowser.open('http://youtube.com', new=2)
print("opened youtube")
elif "github" in query:
SRF.speak("opening github")
webbrowser. open_new_tab("https://github.com/")
elif "code" in query:
SRF.speak("opening visual studio code")
codepath = "C:\\Users\\Sumesh Pandit\\Desktop\\CPP Code\\main.cpp"
os.startfile(codepath)
def googlesearch(query):
SRF.speak('searching on google.....')
url = "https://www.google.co.in/search?q=" + (str(query)) + "&oq="+(str(
query))+"&gs_l=serp.12..0i71l8.0.0.0.6391.0.0.0.0.0.0.0.0..0.0....0...1c..64.serp..0.0.0.UiQhpfaBsuU"
webbrowser.open_new_tab(url)
def playmusic():
SRF.speak("playing music ")
try:
os.mkdir("music_folder")
except FileExistsError:
pass
songs = os.listdir("music_folder")
num = random.randint(0, len(songs))
os.startfile(os.path.join("music_folder", songs[num-1]))