Skip to content

Commit

Permalink
New Project
Browse files Browse the repository at this point in the history
  • Loading branch information
AKmahim committed Apr 14, 2020
1 parent 477cf5a commit 14326fc
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 135 deletions.
81 changes: 55 additions & 26 deletions Jarvis_AI/jarvis.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,38 @@
import pyttsx3
import pyttsx3 #pip install pyttsx3
import speech_recognition as sr #pip install speechRecognition
import datetime
import speech_recognition as sr
import wikipedia as wiki # we have to install this using pip

import wikipedia #pip install wikipedia
import webbrowser
import os
import smtplib

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice',voices[1].id)
#fucntion for speak the content
# print(voices[1].id)
engine.setProperty('voice', voices[0].id)


def speak(audio):
engine.say(audio)
engine.runAndWait()

#fucntion for wish me with date & time

def wishMe():
hour = int(datetime.datetime.now().hour)
if hour>=0 and hour<12:
speak("Good Morning!")

if hour >=0 and hour<12:
speak('Good Morning Mahim !')
elif hour>=12 and hour<18:
speak('Good Afternoon Mahim !')
speak("Good Afternoon!")

else:
speak('Good Evening Mahim !')
speak('I am jarvis. Your virtual assistant. How may I help you sir? ')
speak("Good Evening!")

speak("I am Jarvis Sir.Hello Mahim! Please tell me how may I help you")

#here is a fucntion for take our command using mic voice
def takeCommand():
#it take microphone input and returns output as string
sr.Microphone(device_index=11)
sr.Microphone(device_index=11) #
r = sr.Recognizer()
r.energy_threshold=5000

Expand All @@ -52,18 +57,42 @@ def takeCommand():



#this is the main fucntion
if __name__ == '__main__':

if __name__ == "__main__":
wishMe()
#while True:
text = takeCommand().lower()
#Logic for the task base on input text
if 'wikipedia' in text:
speak('Searching Wikipedia....')
text = text.replace("wikipedia","")
out_data = wiki.summary(text,sentences=2)
speak("According to Wikipedia")
print(out_data)
speak(out_data)
while True:
# if 1:
query = takeCommand().lower()

# Logic for executing tasks based on query
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 google' in query:
webbrowser.open("google.com")

elif 'open stackoverflow' in query:
webbrowser.open("stackoverflow.com")


elif 'play music' in query:
music_dir = 'D:\\Non Critical\\songs\\Favorite Songs2'
songs = os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir, songs[0]))

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

elif 'open code' in query:
codePath = "Visual studio code path"
os.startfile(codePath)
109 changes: 0 additions & 109 deletions Jarvis_AI/main.py

This file was deleted.

0 comments on commit 14326fc

Please sign in to comment.