import pyttsx3 import speech_recognition as sr import webbrowser #This is almost perfect update this more (this is hindi+english+Marathi version jarvis Trasnlation) import pywhatkit import wikipedia import os import keyboard import pyjokes from PyDictionary import PyDictionary as diction from googletrans import Translator Assistant = pyttsx3.init('sapi5') Assistant.setProperty('rate', 250) # Talking Speed Assistant.setProperty('volume', 0.9) Assistant.setProperty('voice', 'com.microsoft.hortense') # English voice # MAIN SPEAK AND LISTEN FUNCTION def Speak(audio): print(" ") Assistant.say(audio) print(f" : {audio}") Assistant.runAndWait() def translate_to_english(text, source_language): translator = Translator() translated_text = translator.translate(text, src=source_language, dest='en').text return translated_text def takecommand(): command = sr.Recognizer() with sr.Microphone() as source: print("Listening......") command.pause_threshold = 0.5 audio = command.listen(source) try: print("Recognizing.....") query = command.recognize_google(audio, language='en-in') print(f"You Said : {query}") except Exception as Error: Speak("What do you mean sir, can you please repeat it") return takecommand() return query # Task's def TaskExe(): Speak("Hello, I am Jarvis, your personal assistant") Speak("How may I help you") def Music(): Speak("Tell ME the name of music sir") musicName = takecommand() if 'the night' in musicName: os.startfile("F:\\IMP\\Songs\\nights.mp3") elif 'play date' in musicName: os.startfile("F:\\IMP\Songs\\playdate.mp3") def OpenApps(): Speak("Okay sir") if 'my disc' in query: os.startfile('F:\\') Speak("Done sir") elif 'games folder' in query: os.startfile('F:\\Games') Speak("Done sir") elif 'google' in query: webbrowser.open('https://google.com/') Speak("Done sir") elif 'youtube' in query: webbrowser.open('https://youtube.com/') Speak("Done sir") elif 'my disk' in query: os.startfile('F:\\') Speak("Done sir") def CloseApps(): Speak("Okay sir closing the app") if 'youtube' in query: os.system("taskkill /F /IM chrome.exe") Speak("App closed sir") elif 'google' in query: os.system("taskkill /F /IM google.exe") Speak("App closed sir") elif 'disc' in query: os.system("taskkill /F /IM F:\\") Speak("App closed sir") elif 'disk' in query: os.system("taskkill /F /IM F:\\") Speak("App closed sir") def YoutubeAuto(): Speak("Whats You Want to do sir?") comm = takecommand() if 'pause' in comm: keyboard.press('space bar') Speak("okay") elif 'restart' in comm: keyboard.press('0') Speak("okay") elif 'mute' in comm: keyboard.press('m') Speak("okay") def Dictionary(): Speak("Opening Dictionary") Speak("Tell me the word") probl = takecommand() if 'meaning' in probl: probl = probl.replace("what is the","") probl = probl.replace("jarvis","") probl = probl.replace("meaning of","") probl = probl.replace("meaning for","") probl = probl.replace("for","") probl = probl.replace("of","") result = diction.meaning(probl) Speak(f"The MEaning for{probl} is {result}") while True: query = takecommand() if 'hello' in query: Speak("Hello Sir , I Am Jarvis.") Speak("Your Personal Assistant.") Speak("How May I Help You?") elif 'who are you' in query: Speak(" i am jarvis a personal assistant") Speak("How May I Help You?") elif 'how are you' in query: Speak("I am Fine What About You Sir") elif 'kaise ho' in query: Speak("I am Fine What About You Sir") elif 'what can you do for me' in query: Speak("i can help you in every tech problems.") Speak("Expect for making you a coffee LOL") elif 'i am fine' in query: Speak("Nice to hear that.") elif 'you are great' in query: Speak("haha thankyou") elif 'nice joke' in query: Speak("haha thankyou") elif 'good night' in query: Speak("Good night sir") Speak("would you like to set an alram?") elif 'good morning' in query: Speak("Good morning sir") Speak("get a coffee and start working") elif 'any task' in query: Speak("no task for today sir") Speak("sir you can improve me by coding") elif 'not funny' in query: Speak("I will try to improve my jokes") elif 'joke was not funny' in query: Speak("I will try to improve my jokes") elif 'no' in query: Speak("Okay sir") elif 'youtube search' in query: Speak("OK Sir, This is what i found") query = query.replace("jarvis","") query = query.replace("youtube search","") translated_query = translate_to_english(query, 'hi') # Translate to English from Hindi (source language) web = 'https://www.youtube.com/results?search_query=' + translated_query Speak("Done Sir!") elif 'google search' in query: Speak("This is what i found for your search sir!") query = query.replace("jarvis","") query = query.replace("google search","") translated_query = translate_to_english(query, 'mr') # Translate to English from Marathi (source language) pywhatkit.search(translated_query) Speak("Done Sir!") elif 'website' in query: Speak("Ok sir , Launching....") query = query.replace("jarvis","") query = query.replace("website","") web1 = query.replace("open","") web2 = 'https://www.' + web1 + '.com' webbrowser.open(web2) Speak("Your website has been launched sir!") elif 'music' in query: Music() elif 'song' in query: Music() elif 'wikipedia' in query: Speak("Searching Wikipedia....") query = query.replace("jarvis","") query = query.replace("wikipedia","") query = query.replace("tell me about","") wiki = wikipedia.summary(query,2) Speak(f"According To Wikipedia : {wiki}") elif 'open google' in query: OpenApps() elif 'open youtube' in query: OpenApps() elif 'open my disc' in query: OpenApps() elif 'open my disk' in query: OpenApps() elif 'games folder' in query: OpenApps() elif 'close google' in query: CloseApps() elif 'close youtube' in query: CloseApps() elif 'you need a break' in query: Speak("okay sir, You can call me Anytime") Speak("Just say wakeup jarvis") break elif 'bye' in query: Speak("Bye sir , You can Call Me whenever you need.") break elif 'youtube' in query: YoutubeAuto() elif 'joke' in query: get = pyjokes.get_joke() Speak(get) elif 'repeat my words' in query: Speak("okay sir!") jj = takecommand() Speak(f"You said : {jj}") elif 'repeat behind me' in query: Speak("okay sir!") jj = takecommand() Speak(f"You said : {jj}") elif 'dictionary' in query: Dictionary() TaskExe()