2

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))
Elydasian
  • 2,016
  • 5
  • 23
  • 41
abhihacker02
  • 51
  • 1
  • 9
  • What else do you expect when changing random names of your libraries? – moritzg Jun 16 '17 at 07:39
  • I don't think the intended setup process involves manually renaming two folders. Have you tried following the [official installation instructions](https://github.com/Uberi/speech_recognition#installing)? – Aran-Fey Jun 16 '17 at 07:39
  • i chnaged the names because it was showing error that no module named speech recognition.please tell what should i do after extracting it in Lib folder – abhihacker02 Jun 16 '17 at 07:50

1 Answers1

1

I had the same error and found the solution with the help of the StackOverflow community here.

The error was that my file name was also speech_recognition and python was checking the file instead of the library. Changing my file name solved the problem.

Sashank SV
  • 50
  • 2
  • 10