AttributeError enter

0 votes

THIS IS THE PIECE OF CODE:-

def takecommand():

    r=sr.Recognizer()

    with sr.Microphone as source:

        r.pause_threshold=1

        r.energy_threshold=320

        audio = r.listen(source)

THIS IS THE ERROR COMING:-

File "c:/Users/user/Desktop/jarvis/jarvis.py", line 28, in takecommand
    with sr.Microphone as source:
AttributeError: __enter__

PLEASE HELP ME OUT WITH THIS ERROR IT WILL OF GREAT HELP.IF MIRE CODE IS NEEDED I AM READY TO GIVE .




Aug 24, 2020 in Python by ARCHISMAN
• 120 points
2,673 views

1 answer to this question.

0 votes

Hey, @Archisman,

in case of this:

with sr.Microphone as a source:

you should write this:

with sr.Microphone() as source:

the thing to do is just you have to add () after sr.microphone.

hope it works......

you can go through this, once you need to dig more regarding this particular query https://www.edureka.co/community/74442/this-kind-of-error-throwing-attributeerror-enter

answered Aug 24, 2020 by Gitika
• 65,770 points

Related Questions In Python

0 votes
1 answer

Why does the AttributeError occur?

This happens because the scipy module doesn't ...READ MORE

answered Dec 4, 2018 in Python by SDeb
• 13,300 points
2,964 views
0 votes
1 answer

Getting AttributeError: 'module' object (scipy) has no attribute 'misc' in Python. How to solve this?

>>> import scipy >>> scipy.misc Traceback (most recent call ...READ MORE

answered Dec 24, 2018 in Python by Nymeria
• 3,560 points
9,418 views
0 votes
1 answer
0 votes
2 answers

Python Pandas error: AttributeError: 'DataFrame' object has no attribute 'rows'

Try this: data=pd.read_csv('/your file name', delim_whitespace=Tru ...READ MORE

answered Dec 10, 2020 in Python by anonymous
• 82,840 points
132,525 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,422 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,042 views
0 votes
2 answers

This kind of error throwing AttributeError: __enter__

I had recently found its solution and ...READ MORE

answered Jul 31, 2020 in Python by lokesh
7,898 views
0 votes
1 answer

AttributeError: type object 'DataFrame' has no attribute 'from_items'

Hi, @Bronson, You can go through this, I ...READ MORE

answered Apr 6, 2020 in Python by Gitika
• 65,770 points
5,303 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP