10 Lines of Code For Your Own AI Assistant ( Jarvis )
program is a very basic implementation of a virtual assistant and can be expanded upon with more functions and features. pythonCopy code import speech_recognition as sr import pyttsx3 import webbrowser import datetime # Set up speech recognition r = sr.Recognizer() with sr.Microphone() as source: print("Listening...") r.pause_threshold = 1 audio = r.listen(source) # Initialize text-to-speech engine engine = pyttsx3.init() # Set up wake-up keyword wake_word = "Jarvis" # Define function to convert text to speech def speak(text): engine.say(text) engine.runAndWait() # Define function for opening a website def open_website(url): webbrowser.open(url) speak("Opening website.") # Define function for telling the time def tell_time(): time = datetime.datetime.now().strftime("%I:%M %p") speak(f"The time is {time}.") # Check if wake-up keyword is detected if wake_word in r.recognize_google(audio): speak(...