-
Notifications
You must be signed in to change notification settings - Fork 0
/
browsercommands.py
40 lines (33 loc) · 1.41 KB
/
browsercommands.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
import audioprocessor as ap
import webbrowser
def browserCommands(text, answer):
if(text == "open youtube"):
webbrowser.open("http://youtube.com")
elif(text == "open google"):
webbrowser.open("http://google.com")
elif(text == "open stack overflow"):
webbrowser.open("http://stackoverflow.com")
elif("search youtube" in text):
query = text.replace("search youtube", "").strip()
if(query == ""):
ap.say("Sorry! I cannot find anything to search for...")
else:
answer = answer.replace("{searchText}", query)
ap.say(answer)
webbrowser.open("https://www.youtube.com/results?search_query=" + query)
elif("search google" in text):
query = text.replace("search google", "").strip()
if(query == ""):
ap.say("Sorry! I cannot find anything to search for...")
else:
answer = answer.replace("{searchText}", query)
ap.say(answer)
webbrowser.open("https://www.google.com/search?q=" + query)
elif("search stackoverflow" in text):
query = text.replace("search stackoverflow", "").strip()
if(query == ""):
ap.say("Sorry! I cannot find anything to search for...")
else:
answer = answer.replace("{searchText}", query)
ap.say(answer)
webbrowser.open("https://stackoverflow.com/search?q=" + query)