0% found this document useful (0 votes)
24 views5 pages

Python Voice Assistant Bot Code

The document outlines a Python script for a voice-activated assistant named JARVIS, which utilizes various libraries for speech recognition, web browsing, and email functionalities. It includes features such as searching Wikipedia, playing music, sending emails, and providing weather updates. The script is designed to respond to user commands and perform tasks accordingly.

Uploaded by

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

Python Voice Assistant Bot Code

The document outlines a Python script for a voice-activated assistant named JARVIS, which utilizes various libraries for speech recognition, web browsing, and email functionalities. It includes features such as searching Wikipedia, playing music, sending emails, and providing weather updates. The script is designed to respond to user commands and perform tasks accordingly.

Uploaded by

ashishjonson22
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python BOT

import pyttsx
import wikipedi
import speech_recognition as s
import webbrowse
import datetim
import o
import sy
import smtpli
from news import speak_new
from diction import translat
from loc import weathe
from youtube import yo
engine = [Link](
voices = [Link]('voices'
[Link]('voice', voices[0].id

# print(voices[0].id

def speak(audio)
[Link](audio
[Link](

def takeCommand()
r = [Link](
with [Link]() as source
print('Listening...'
r.pause_threshold =
r.energy_threshold = 49
r.adjust_for_ambient_noise(source, duration=1.5
audio = [Link](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 quer

def wishMe()
hour = int([Link]().hour
if hour >= 0 and hour < 12
speak("Good Morning SIR"
elif hour >= 12 and hour < 18
speak("Good Afternoon SIR"

else
speak('Good Evening SIR'

weather(
speak('I am JARVIS. Please tell me how can I help you SIR?'

def sendEmail(to, content)


server = [Link]('[Link]', 587
[Link](
[Link](
[Link]('email', 'password'
[Link]('email', to, content
[Link](

if __name__ == '__main__'
chrome_path = 'C:\Program Files
(x86)\Google\Chrome\Application\[Link]
[Link]
'chrome', None, [Link](chrome_path)
wishMe(
while True
query = takeCommand().lower(
if 'wikipedia' in query
speak('Searching Wikipedia....'
query = [Link]('wikipedia', ''
results = [Link](query, sentences=2
:

'

'

speak('According to Wikipedia'
print(results
speak(results

elif 'youtube downloader' in query


exec(open('youtube_downloader.py').read()

elif 'voice' in query


if 'female' in query
[Link]('voice', voices[1].id
else
[Link]('voice', voices[0].id
speak("Hello Sir, I have switched my voice. How is it?"

if 'jarvis are you there' in query


speak("Yes Sir, at your service"
elif 'open youtube' in query

[Link]('chrome').open_new_tab('[Link]

elif 'open google' in query


[Link]('chrome').open_new_tab('[Link]

elif 'open stackover ow' in query


[Link]('chrome').open_new_tab('https://
stackover [Link]'

elif 'play music' in query


[Link] le("D:\\RoiNa.mp3"

elif 'search youtube' in query


speak('What you want to search on Youtube?'
you(takeCommand()
elif 'the time' in query
strTime = [Link]().strftime("%H:%M:%S"
speak(f'Sir, the time is {strTime}'

elif 'search' in query


speak('What do you want to search for?'
search = takeCommand(
url = '[Link] + searc
[Link]('chrome').open_new_tab
fl
:

fi
)

fl
:

url
speak('Here is What I found for' + search

elif 'location' in query


speak('What is the location?'
location = takeCommand(
url = '[Link] + location + '/&amp;
[Link]('chrome').open_new_tab(url
speak('Here is the location ' + location

elif 'your master' in query


speak('Gaurav is my master. He created me couple of days ago'
elif 'your name' in query
speak('My name is JARVIS'
elif 'stands for' in query
speak('J.A.R.V.I.S stands for JUST A RATHER VERY INTELLIGENT
SYSTEM'
elif 'open code' in query
[Link] le
"C:\\Users\\gs935\\AppData\\Local\\Programs\\Microsoft VS
Code\\[Link]"

elif 'shutdown' in query


[Link]('shutdown /p /f'

elif 'github' in query


[Link]('chrome').open_new_tab
'[Link]

elif 'remember that' in query


speak("what should i remember sir"
rememberMessage = takeCommand(
speak("you said me to remember"+rememberMessage
remember = open('[Link]', 'w'
[Link](rememberMessage
[Link](

elif 'do you remember anything' in query


remember = open('[Link]', 'r'
speak("you said me to remember that" + [Link]()

elif 'sleep' in query


)

fi
)

'

[Link](

elif 'dictionary' in query


speak('What you want to search in your intelligent dictionary?'
translate(takeCommand()

elif 'news' in query


speak('Ofcourse sir..'
speak_news(

elif 'email to gaurav' in query


try
speak('What should I say?'
content = takeCommand(
to = 'email
sendEmail(to, content
speak('Email has been sent!'

except Exception as e
speak('Sorry sir, Not able to send email at the moment')
:

'

You might also like