def wishme(): hour = int(datetime.datetime.now().hour) if hour >= 0 and hour <= 12: sar.speak("Good morning ! ") elif hour >= 12 and hour < 18: sar.speak("Good aftenoon ! ") else: sar.speak("Good evening! ") sar.speak("It's Karen. How may i help you ?")
def wiki(query): try: print("Searching on Wikipedia.....") sar.speak('Searching on Wikipedia.....') query = query.replace("search", "") query = query.replace("wikipedia", "") query = query.replace("on", "") results = wikipedia.summary(query, sentences=2) sar.speak("According to wikipedia - ") sar.speak(results) except: print("error- KAREN did not recognized what you said ") sar.speak("Didn't get that. Say that again!")
def tellMeAJoke(): sar.speak( "A bear walks into a bar and says, Give me a whiskey and … cola. Why the big pause? asks the bartender. The bear shrugged. I’m not sure; I was born with them." )
import functions as F import webbrowser if __name__ == "__main__": print("____KAREN____") F.wishme() while True: query = sar.takecommand().lower() if 'wikipedia' in query : #to search stuff on wikipedia F.wiki(query) elif 'open youtube' in query: sar.speak ('opening youtube...') webbrowser.open('http://youtube.com') elif 'open gmail' in query: sar.speak ('opening gmail...') webbrowser.open('http://gmail.com') elif 'open github' in query: sar.speak ('opening github....') webbrowser.open('http://github.com') elif "google search" in query: query = query.replace("google search","") sar.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(url)