Founder-of-Mak-Academy / Jarvis-AI

MIT License
12 stars 20 forks source link

JARVIS. A student of yours from udemy #1

Open tabindumbe opened 3 years ago

tabindumbe commented 3 years ago

Hello sir i have a problem with the Jarvis coding. My code takes in input, recognizes input but doesn't give out voice output

import pyttsx3 #pip install pyttsx3 import speech_recognition as sr import datetime import wikipedia

engine = pyttsx3.init()

def speak(audio): engine.say(audio) engine.runAndWait()

def time_(): Time=datetime.datetime.now().strftime('%I:%M:%S') speak ("The current time is") speak(Time)

def date_(): year = datetime.datetime.now().year month = datetime.datetime.now().month date = datetime.datetime.now().day speak("The current date is") speak(date) speak(month) speak(year)

def wishme(): speak("Welcome back Mac-Roy!") time() date()

#greetings

hour = datetime.datetime.now().hour

if hour>=6 and hour<12:
    speak("Good Morning Sir!")
elif hour>=12 and hour<18:
    speak("Good Afternoon Sir!")
elif hour>=18 and hour<24:
    speak("Good Evening Sir!")
else:
    speak("Good Night Sir!")

speak("Jarvis at your service")
speak("What can i do for you sir?")

def TakeCommand(): r = sr.Recognizer() with sr.Microphone() as source: print("Listening...") r.pause_threshold = 1 audio = r.listen(source) try: print("Recognizing...") query = r.recognize_google(audio, language='en-pk') print(query)

except Exception as e:
    print(e)
    print("Say that again please...")
    return "None"
return query

if name == "main":

wishme()

while True:
    query = TakeCommand().lower()

#All commands will be stored in lower case in query
#for easy recognition

if 'time' in query: #tells the time when asked
    time_()

elif 'date' in query: #tells date when asked
    date_()

elif 'wikipedia' in query:
    speak("Searching........")
    query=query.replace('wikipedia','')
    result=wikipedia.summary(query,sentences=3)
    speak('According to wikipedia')
    print(result)
    speak(result)
Founder-of-Mak-Academy commented 3 years ago

Hi tabindumbe, Is it showing any kind of error in the terminal?

tabindumbe commented 3 years ago

No error in the terminal

Sent from my iPhone

On 21 Apr 2021, at 10:11, Mak @.***> wrote:

 Hi tabindumbe, Is it showing any kind of error in the terminal?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.