I downloaded a speech recognition from pypy.
It was 3.6.0 version and extracted it in Lib folder inside python folder. Its name was something speechrecognition 3.6 and I changed it to speech_recognition and then it was not showing an error like "no such module", but inside that, there was another folder with the same name so I changed it also and now even though it has Recognizer folder it says:
AttributeError: module 'speech_recognition' has no attribute 'Recognizer'
Please help, I am new to python.
Code:
import speech_recognition as sr
import pyaudio
# Record Audio
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)
# Speech recognition using Google Speech Recognition
try:
# for testing purposes, we're just using the default API key
# to use another API key, use `r.recognize_google(audio,
key="GOOGLE_SPEECH_RECOGNITION_API_KEY")`
# instead of `r.recognize_google(audio)`
print("Speech was:" + r.recognize_google(audio, language = "en-us",
show_all=False))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service;
{0}".format(e))