import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
import smtplib
import pywhatkit
a = [Link]('sapi5')
voices = [Link]('voices')
[Link]('voice', voices[1].id)
def speak(audio):
[Link](audio)
[Link]()
def wishMe():
hour = int([Link]().hour)
if hour>=0 and hour<12:
speak("Hello,Good Morning!")
elif hour>=12 and hour<18:
speak("Hello,Good Afternoon!")
else:
speak("Hello,Good Evening!")
speak("I am sesa. Please tell me how may I help you")
def take():
#It takes microphone input from the user and returns string output
r = [Link]()
with [Link]() as source:
print("Listening...")
r.pause_threshold = 1
audio = [Link](source)
speak(audio)
try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"User said: {query}\n")
except Exception as e:
# print(e)
print("Say that again please...")
return "None"
return query
if __name__ == "__main__":
wishMe()
while True:
# if 1:
query = take().lower()
# Logic for executing tasks based on query
if 'wikipedia' in query:
speak('Searching Wikipedia...')
query = [Link]("wikipedia", "")
results = [Link](query, sentences=2)
speak("According to Wikipedia")
print(results)
speak(results)
elif 'open youtube' in query:
speak("Opening Youtube..")
[Link]("[Link]")
elif 'open Google' in query:
speak("Opening Google..")
[Link]("[Link]")
elif 'open photos' in query:
speak("Opening photos from your device..")
codePath = "C:\\Users\\HP\\Pictures"
[Link](codePath)
elif 'open documents' in query:
speak("Opening documents from your device..")
codePath = "C:\\Users\\HP\\Documents"
[Link](codePath)
elif 'open downloads' in query:
speak("Opening downloads from your device..")
codePath = "C:\\Users\\HP\\Downloads"
[Link](codePath)
elif 'desktop' in query:
speak("Please wait..")
codePath = "C:\\Users\\HP\\Desktop"
[Link](codePath)
elif 'play music' in query:
speak("Please choose the song you want to be played..")
music_dir = "C:\\Users\\HP\\Music"
songs = [Link](music_dir)
print(songs)
[Link]([Link](music_dir))
elif 'the time' in query:
strTime = [Link]().strftime("%H:%M:%S")
speak(f"the time is {strTime}")
elif 'who are you' in query:
speak('I am sesa')
elif 'what can you do' in query:
speak('I can open utube,google,downloads,documents,desktop and
photos...i can play music..i can tell wikipedia..and i can search for the things
you want..')
elif 'search' in query:
import wikipedia as googlescrap
query=[Link]("google search","")
query=[Link]("google","")
speak("Here are your results..")
try:
[Link](query)
result=[Link](query,2)
print(result)
speak(result)
except:
speak("No readable data available...")
elif 'exit' in query or 'bye' in query or 'quit' in query:
speak("Ok bye...I am quiting....Thanks for your time.")
exit()