J.A.R.V.I.S.

import pyttsx3
import speech_recognition as sr
import datetime
import pyaudio 
import wikipedia
import webbrowser
import os

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voices', voices[1].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("Hello Sir, I am Ethan. How can I help you in any way? Please tell me.")
 
def takeCommand():
    # It takes microphone input from the 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 

if __name__ == "__main__":
   wishMe()
    #  If you understand till here then ok but if you are not able to understand then type comment or send through Email.
    if 1:
        query = takeCommand().lower()
        if 'wikipedia' in query:
            speak('Searching Wikipedia....')
            speak("Please Wait...")
            query = query.replace("wikipedia""")
            results = wikipedia.summary(query, sentences=4)
            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 'open coding zone' in query:
            webbrowser.open("chinmaycodes.blogspot.com")

        elif 'open amazon' in query:
            webbrowser.open("amazon.in"

        elif 'open amazon.com' in query:
            webbrowser.open("amazon.com")
   
        elif 'open google meet' in query:
            webbrowser.open("meet.google.com")

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

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

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

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

        elif 'open intel' in query:
            webbrowser.open("intel.in")

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

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

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

        elif 'open coca-cola' in query:
            webbrowser.open("coca-colacompany.com")

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

        elif 'open reliance industries' in query:
            webbrowser.open("ril.com")

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

        elif 'open 7-eleven' in query:
            webbrowser.open("7-eleven.com")

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

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

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

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

        elif 'open python website' in query:
            webbrowser.open("python.org")

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

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


        elif 'play music' in query:
            music_dir = 'C:\\J Drive\\Music\\W.W.E.'
            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"Boss, the time is {strTime}")

        elif 'open vs code' in query:
            codePath =  "C:\\VS Code\\Microsoft VS Code\\Code.exe"
            os.startfile(codePath)
After this on 10/August/2020 I will post about how can you post Email through your personal A.I.

Comments

  1. Sir please tell me how to send Email.

    ReplyDelete

Post a Comment

Popular Posts