-
Notifications
You must be signed in to change notification settings - Fork 272
Description
Install these before running:
pip install speechrecognition pyttsx3 opencv-python
import speech_recognition as sr
import pyttsx3
import cv2
Initialize speech engine
engine = pyttsx3.init()
def speak(text):
engine.say(text)
engine.runAndWait()
Voice Recognition
def listen():
r = sr.Recognizer()
with sr.Microphone() as source:
print("🎤 Jarvis Listening...")
audio = r.listen(source)
try:
text = r.recognize_google(audio)
print("👉 You said:", text)
return text
except:
speak("Sorry, I didn't catch that.")
return ""
Video Assistant Window
def video_window():
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
cv2.imshow("🖥️ Jarvis Video Assistant", frame)
if cv2.waitKey(1) & 0xFF == ord('q'): # Press Q to exit
break
cap.release()
cv2.destroyAllWindows()
Main Loop
speak("Hello Johan sir, I am Jarvis. Say something!")
command = listen().lower()
if "video" in command:
speak("Opening video window for you.")
video_window()
else:
speak("Okay, I am ready for your next command.")