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
841 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,870 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,270 points
1,061 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,520 points
5,698 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,720 points
66,559 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 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 2,032 views
0 votes
0 answers
+4 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,810 points
1,555 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
3,471 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,870 points
2,956 views