This is the peice of code which had AttributeError: __enter__ with sr.Microphone as source: It got resolved by adding '()' as below: with sr.Microphone() as source: