0
import speech_recognition as sr
import datetime

engine = pyttsx3.init('sapi5')

voices = engine.getProperty('voices')

#print(voices[1].id)

engine.setProperty('voice', voices[1].id)

def speak(audio):

engine.say(audio)

engine.runAndWait()

def wishMe():

hour = int(datetime.datetime.now().hour)

if hour>=0 and hour<12:

speak("Good Morning")

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

def takeCommand():#it takes microphone input from the user and returns string output

    Recognition = sr.Recognizer()
    with sr.Microphhone() as source:
       print("listening...")
       r.pause_threshold = 1
       audio = r.listen(source,timeout = 1, phrase_time_limit= 10)
    try:
    
       print("Recognition...")
       query = r.recognize_google(audio, Language= 'en-in')
       print(f"User said: {query}\n") 
    
    except Exception as e:
        print(e)
        print("Say that again...")
        return "None"
    return query

if name == "main":speak("")

wishMe()

takeCommand()

I AM MAKING JARVIS FROM AN YOUTUBE TUTORIAL BUT IA M FACING A PROBLEM...I HAD MADE FROM SEEING AN TUTORIAL FROM YOUTUBE..

BUT I CAN'T UNDERSTAND WHY Speech_Recognition HAS NO ATTRIBUTE AND WHAT IS MEANT BY ATTRIBUTR WITH THIS MODULE.

Chris Albert
  • 2,462
  • 8
  • 27
  • 31
KONKPIT
  • 19
  • 2
  • 1
    Well, the reason is probably that this thing is called a 'Microphone' and not 'Microphhone' with 2 h's, as you wrote it. Otherwise, please format your code in a better readable way and don't write in ALLCAPS... – Elmar Zander Dec 05 '22 at 12:47

0 Answers0