forked from Aapoorva/VoiceControlProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoogle_search.py
More file actions
36 lines (35 loc) · 1.23 KB
/
google_search.py
File metadata and controls
36 lines (35 loc) · 1.23 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
# imports
import webbrowser
import tts
import SpeechRego as sr
#------------------------------------------------------------------------------------
# search gogle function
def search_google(filtered_query):
result = 0
# keywords to remove
remv_keywords = ['search','google','on','about','the','find','ok','do','a']
# final list of words to be searched
final_key=[]
# append words other than remv_keywords to final_key
for word in filtered_query:
if word in remv_keywords:
pass
else:
final_key.append(word)
# if no keyword given ask for keyword
if final_key == [] :
tts.convert_text_n_speak("What should i search")
user_input = sr.get_audio_to_text()
user_input = user_input.lower().strip().split()
result = search_google(user_input)
# to avoid ruuning 2 times
if result == 0 :
# string of search words
search_words=str()
for word in final_key:
search_words = search_words + ' ' + word
print('searching for '+search_words)
webbrowser.open_new_tab('https://www.google.com/search?q='+search_words)
tts.convert_text_n_speak("Search results ready")
result = 1
return result