Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jarvis #371

Open
RAISTAR32 opened this issue Oct 9, 2023 · 1 comment
Open

Jarvis #371

RAISTAR32 opened this issue Oct 9, 2023 · 1 comment

Comments

@RAISTAR32
Copy link

import speech_recognition as sr

def take_command():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
audio = r.listen(source)

try:
    command = r.recognize_google(audio).lower()
    print("You said: " + command)
except sr.UnknownValueError:
    print("Sorry, I did not understand that.")
    command = take_command()

return command

import pyttsx3

def speak(text):
engine = pyttsx3.init()
engine.say(text)
engine.runAndWait()
def process_command(command):
if "hello" in command:
speak("Hello! How can I assist you?")
elif "bye" in command:
speak("Goodbye!")
exit()
else:
speak("I'm not sure how to respond to that.")
while True:
command = take_command()
process_command(command)

@RAISTAR32
Copy link
Author

import speech_recognition as sr

def take_command():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening...")
audio = r.listen(source)

try:
    command = r.recognize_google(audio).lower()
    print("You said: " + command)
except sr.UnknownValueError:
    print("Sorry, I did not understand that.")
    command = take_command()

return command

import pyttsx3

def speak(text):
engine = pyttsx3.init()
engine.say(text)
engine.runAndWait()
def process_command(command):
if "hello" in command:
speak("Hello! How can I assist you?")
elif "bye" in command:
speak("Goodbye!")
exit()
else:
speak("I'm not sure how to respond to that.")
while True:
command = take_command()
process_command(command)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant