0% found this document useful (0 votes)
18 views2 pages

Jarvis

Jarvis digital assistant code

Uploaded by

Shivansh Singh
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)
18 views2 pages

Jarvis

Jarvis digital assistant code

Uploaded by

Shivansh Singh
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/ 2

import speech_recognition as sr

import pyttsx3

import pywhatkit

import datetime

import wikipedia

import pyjokes

listener = sr.Recognizer()

engine = pyttsx3.init()

voices = engine.getProperty('voices')

engine.setProperty('voices', voices[1].id)

def talk(text):

engine.say(text)

engine.runAndWait()

def take_command():

try:

with sr.Microphone() as source:

print('listening...')

voice = listener.listen(source)

command = listener.recognize_google(voice)

command = command.lower()

if 'jarvis' in command:

print(command)

except:

pass

return command
def run_jarvis():

command = take_command()

print(command)

if 'play' in command:

song = command.replace('play', '')

talk('playing' + song)

pywhatkit.playonyt('song')

elif 'time' in command:

time = datetime.datetime.now().strftime('%I:%M %p')

print(time)

talk('current time is ' + time)

elif ' who the heck is' in command:

person = command.replace('who the heck is', '')

info = wikipedia.summary(person, 1)

print(info)

talk(info)

elif 'joke' in command:

talk(pyjokes.get_joke())

run_jarvis()

You might also like