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

Main Py

Uploaded by

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

Main Py

Uploaded by

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

import os

import pyttsx3
import speech_recognition as sr
import datetime
import webbrowser
import json
import psutil
import customtkinter as ctk
import pyautogui
import pyjokes
import keyboard
from modules import memory

engine = pyttsx3.init()
engine.setProperty('rate', 175)
engine.setProperty('volume', 1)

with open('config/memory.json') as f:
config = json.load(f)

user = config['user']
wake_word = config['wake_word']
greeting = config['preferences']['greeting']

def speak(text):
print("JARVIS:", text)
engine.say(text)
engine.runAndWait()

def wish_me():
hour = datetime.datetime.now().hour
if 0 <= hour < 12:
speak(f"Good Morning {user}!")
elif 12 <= hour < 18:
speak(f"Good Afternoon {user}!")
else:
speak(f"Good Evening {user}!")
speak(greeting)

def take_command():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
audio = r.listen(source)
try:
print("Recognizing...")
query = r.recognize_google(audio, language='en-in')
print(f"User said: {query}\n")
except Exception:
speak("Sorry, could you say that again?")
return "None"
return query.lower()

def run_jarvis():
wish_me()
while True:
query = take_command()
if wake_word in query:
speak("Initializing Jarvis Mode...")

elif 'open youtube' in query:


webbrowser.open("https://youtube.com")

elif 'joke' in query:


speak(pyjokes.get_joke())

elif 'battery' in query:


battery = psutil.sensors_battery()
speak(f"Battery is at {battery.percent} percent")

elif 'exit' in query or 'goodbye' in query:


speak("Signing off. Goodbye Jai!")
break

if __name__ == "__main__":
run_jarvis()

You might also like