-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchNow.py
More file actions
143 lines (132 loc) · 4.29 KB
/
SearchNow.py
File metadata and controls
143 lines (132 loc) · 4.29 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#import speech_recognition
#import pyttsx3
#import pywhatkit
#import wikipedia
#import webbrowser
#
#
#def takeCommand():
# r = speech_recognition.Recognizer()
# with speech_recognition.Microphone() as source:
# print("Listening.....")
# r.pause_threshold = 1
# r.energy_threshold = 300
# audio = r.listen(source,0,4)
# try:
# print("Understanding..")
# query = r.recognize_google(audio,language='en-in')
# print(f"You Said: {query}\n")
# except Exception as e:
# print("Say that again")
# return "None"
# return query
#
#query = takeCommand().lower()
#
#engine = pyttsx3.init("sapi5")
#voices = engine.getProperty("voices")
#engine.setProperty("voice", voices[0].id)
#engine.setProperty("rate",170)
#
#def speak(audio):
# engine.say(audio)
# engine.runAndWait()
#
#def searchGoogle(query):
# if "google" in query:
# import wikipedia as googleScrap
# query = query.replace("jarvis","")
# query = query.replace("google search","")
# query = query.replace("google","")
# speak("This is what I found on google")
#
# try:
# pywhatkit.search(query)
# result = googleScrap.summary(query,1)
# speak(result)
#
# except:
# speak("No speakable output available")
#
#def searchYoutube(query):
# if "youtube" in query:
# speak("This is what I found for your search!")
# query = query.replace("youtube search","")
# query = query.replace("youtube","")
# query = query.replace("jarvis","")
# web = "https://www.youtube.com/results?search_query=" + query
# webbrowser.open(web)
# pywhatkit.playonyt(query)
# speak("Done, Sir")
#
#def searchWikipedia(query):
# if "wikipedia" in query:
# speak("Searching from wikipedia....")
# query = query.replace("wikipedia","")
# query = query.replace("search wikipedia","")
# query = query.replace("jarvis","")
# results = wikipedia.summary(query,sentences = 2)
# speak("According to wikipedia..")
# print(results)
# speak(results)
import webbrowser
import speech_recognition
import pyttsx3
import pywhatkit
import wikipedia
def takeCommand():
r = speech_recognition.Recognizer()
with speech_recognition.Microphone() as source:
print("Listening....")
r.pause_threshold = 1
r.energy_threshold = 300
audio = r.listen(source,0,4)
try:
print("Understanding....")
query = r.recognize_google(audio,language='en-in')
print(f"You Said: {query}\n")
except Exception as e:
print("Say that again")
return "None"
return query
query = takeCommand().lower()
engine = pyttsx3.init("sapi5")
voices = engine.getProperty("voices")
engine.setProperty("voice", voices[0].id)
rate = engine.setProperty("rate",170)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def searchGoogle(query):
if "google" in query:
import wikipedia as googleScrap
query = query.replace("nova","")
query = query.replace("google search","")
query = query.replace("google","")
speak("This is what i found on google")
try:
pywhatkit.search(query)
result = googleScrap.summary(query,1)
speak(result)
except:
speak("No speakable output available")
def searchYoutube(query):
if "youtube" in query:
speak("This is what i found for your search!")
query = query.replace("youtube search","")
query = query.replace("youtube","")
query = query.replace("nova","")
web = "https://www.youtube.com/results?search_query=" + query
webbrowser.open(web)
pywhatkit.playonyt(query)
speak("Done, Mam")
def searchWikipedia(query):
if "wikipedia" in query:
speak("Searching from wikipedia....")
query = query.replace("wikipedia","")
query = query.replace("search wikipedia","")
query = query.replace("nova","")
Results = wikipedia.summary(query,sentences = 2)
speak("According to wikipedia..")
print(Results)
speak(Results)