I'm trying to run a speech recognition using the Speech Recognition Project
I installed SpeechRecognition as illustrated. My code ran correctly for a few times.
I was trying to input different files. Now I started getting the following error:
import speech_recognition as sr
Traceback (most recent call last):
File "<ipython-input-1-a4d5c9aae5d0>", line 1, in <module>
import speech_recognition as sr
File "/Users/Sashank/Documents/Deep_Learning_A_Z/Personal Projects/Speech recognition/speech_recognition.py", line 7, in <module>
r = sr.Recognizer()
AttributeError: module 'speech_recognition' has no attribute 'Recognizer'
The confusing thing is that I'm only executing the first line of the code, which is to import the library. And it returns the error.
import speech_recognition as sr
And the error seems to be corresponding to the next line of code, which I've not yet executed:
r = sr.Recognizer()
I'm new to both programming as well as to python. I'm using spyder3. I've restarted the kernel a few times. I tried to install SpeechRecognition again on terminal. I closed and opened spyder also a few times, but now facing the same error again and again.
Please help.
Full Code:
# Speech Recognition
# Importing Library
import speech_recognition as sr
# Creating a recognition object
r = sr.Recognizer()
# Extracting the audio & removing ambient noice
audio_file = sr.AudioFile('ambient_noise_recording.wav')
with audio_file as source:
r.adjust_for_ambient_noise(source)
audio = r.record(source)
# Recognize the audio
r.recognize_google(audio)