By SOURAV DASH
I thought it would be cool to create a personal assistant in Python. If you are into movies you may have heard of Jarvis, an A.I. based character in the Iron Man films.
import pyttsx3 | |
import speech_Recognition as sr | |
import datetime | |
import wikipedia | |
import webbrowser | |
import os | |
import smtplib | |
engine = pyttsx3.init('sapi5') | |
voices = engine.getproperty('voices') | |
print(voices[0].id) | |
engines.setproperty('voice', voices[0].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!") | |
speak("I am Jarvis sir. please tell me how may I help you") | |
def takeCommand(): | |
#it takes Microphone input from 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: | |
# print(e) | |
print("Say that again please...") | |
return "None" | |
return "query" | |
def sendEmail(to,content): | |
server=smtplib.SMTP('smtp.gmail.com',587) | |
server.ehlo() | |
server.starttls() | |
server.login('[email protected]','your-password') | |
server.sendmail('[email protected]',to,content) | |
Submitted by SOURAV DASH (Sourav)
Download packets of source code on Coders Packet
Comments