0% found this document useful (0 votes)
3 views3 pages

Document 1

The document is a Python script that implements a voice assistant named Jarvis, which can perform tasks such as sending emails, searching Wikipedia, and opening websites. It utilizes libraries like pyttsx3 for text-to-speech, speech_recognition for voice commands, and smtplib for email functionality. The assistant greets the user based on the time of day and listens for commands in Bengali.

Uploaded by

nomanislam2415
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

Document 1

The document is a Python script that implements a voice assistant named Jarvis, which can perform tasks such as sending emails, searching Wikipedia, and opening websites. It utilizes libraries like pyttsx3 for text-to-speech, speech_recognition for voice commands, and smtplib for email functionality. The assistant greets the user based on the time of day and listens for commands in Bengali.

Uploaded by

nomanislam2415
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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')
engine.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("subho sokaal Nomaan Sir!")

elif hour >= 12 and hour < 18:


speak("subho duupur Nomaan sir!")

else:
speak("subho shondha Nomaan sir!")

speak("Nomaan sir , ami jarvis. Bolen ami apnar jonno ki help korte
paari")

def takeCommand():

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='ben-in')
print(f"User said: {query}\n")
except Exception as 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]', 'noman@mehek')
server.sendmail('[email protected]', to, content)
server.close()

if __name__ == "__main__":
wishMe()
while True:
query = takeCommand().lower()

if 'wikipedia' in query:
speak('Searching Wikipedia...')
query = query.replace("wikipedia", "")
results = wikipedia.summary(query, sentences=2)
speak("According to Wikipedia")
print(results)
speak(results)

elif 'open youtube' in query:


webbrowser.open("youtube.com")

elif 'open my youtube playlist' in query:


playlist_url ='https://www.youtube.com/watch?
v=qfdShSZZxlg&list=PLCct-PU6KCmM7G-JubjPUt76Oa58zxmzB'
webbrowser.open(playlist_url)

elif 'open google' in query:


webbrowser.open("google.com")

elif 'open instagram' in query:


webbrowser.open("instagram.com")

elif 'open stackoverflow' in query:


webbrowser.open("stackoverflow.com")
elif 'shut down' in query:
os.system('shutdown /s /t 1')

elif 'play music' in query:


music_dir = r'C:\Users\noman\music'
songs = os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir, songs[0]))

elif 'open her pictures' in query:


pictures_path = r'C:\Program Files\Acess here(personal)\
desktop'
os.startfile(pictures_path)

elif 'the time' in query:


strTime = datetime.datetime.now().strftime("%H:%M:%S")
speak(f"Sir, the time is {strTime}")

elif 'email to Noman' in query:


try:
speak("What should I say?")
content = takeCommand()
to = "[email protected]"
sendEmail(to, content)
speak("Email has been sent!")
except Exception as e:
print(e)
speak("Sorry Nomaan sir. I am not able to send this
email")

You might also like