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,483 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,910 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,793 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
8,937 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,880 points
130,350 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,067 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
3,486 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,514 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,910 points
5,006 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