0
votes

I got some code from google for speech recognition when i try to run that code i'm getting "NotImplementedError" please see the below code and help me.I'm using Mac.

import speech_recognition as sr
r = sr.Recognizer()
with sr.Recognizer() as source:
print("Speak Anything")
audio = r.listen(source)

try:    
    text = r.recognize_google(audio)
    print("you said:{}".format(text))
except NotImplementedError:
    print("Sorry could not recognise your voice")

Traceback (most recent call last):

File "", line 4, in with sr.Recognizer() as source:

File "/Users/chiku/anaconda3/lib/python3.5/site-packages/speech_recognition/init.py", line 51, in enter raise NotImplementedError("this is an abstract class")

NotImplementedError: this is an abstract class

Traceback (most recent call last):

File "", line 4, in with sr.Recognizer() as source:

File "/Users/chiku/anaconda3/lib/python3.5/site-packages/speech_recognition/init.py", line 51, in enter raise NotImplementedError("this is an abstract class")

NotImplementedError: this is an abstract class

1
Maybe you should speak w/ whomever you got this code from?Scott Hunter

1 Answers

1
votes

In the line above, you instantiate a Recognizer object, then you try to use the uninstatiated class in the problem line. Should that be

with r as source:
    ...