import pyttsx3
import speech_recognition as sr
import datetime
import wikipedia
import webbrowser
import os
import subprocess as sp
engine = pyttsx3.init('sapi5')
voices = engine.getProperty ('voices')
engine.setProperty('voice',voices [1].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wishme():
hour = int(datetime.datetime.now().hour)
if hour >= 0 and hour <= 12:
speak("Good Morning!")
elif hour >= 12 and hour <=18:
speak("Good Afternoon!")
else:
speak("Good Evening!")
def takecommand():
#It takes microphone input from the user and returns string output
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
r.pause_threshold = 1
audio = r.listen(source)
try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"User said: {query}\n")
except Exception as e:
speak('sir, Say that again please...')
return "None"
return query
def username():
speak('what should i call you sir')
uname = takecommand()
speak('welcome mister' or 'welcome miss')
speak(uname)
speak("How can i Help you, Sir")
if __name__ == "__main__":
wishme()
username()
#speak('Before using me please give come input')
#a=str(input('Enter notepade app path if you wanna to use it with me:'))
while True:
query = takecommand().lower()
if "wikipedia" in query:
speak('searching wikipedia...')
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=3)
speak("According to wikipedia", results)
elif "open google" in query:
speak('opening google')
webbrowser.open("google.com")
# most asked question from google Assistant
elif "will you be my gf" in query or "will you be my bf" in query:
speak("I'm not sure about, may be you should give me some time")
elif "how are you" in query:
speak("I'm fine, glad you me that")
elif "i love you" in query:
speak("It's hard to understand")
elif 'open notepad' in query:
pn="Notepad.exe"
sp.Popen([pn])
Hey Madhusudan
ReplyDeleteHey Madhusudan
ReplyDelete