Python Speech Recognition: 'module' object has no attribute 'microphone'

只谈情不闲聊 提交于 2019-12-03 14:57:31

For 2.7: The PyPI SpeechRecognition page mentions Microphone rather than microphone. Try capitalizing the name. If you had tried

>>> import speech_recognition as sr
>>> dir(sr)

to see what attributes the module does have, you would likely have discovered the mistake.

For 3.4, I suspect you downloaded and installed the sr module only for 2.7. At a command line (using the Windows version, adjust for another OS as needed)

.../python34/Scripts> pip install SpeechRecognition

should install for 3.4.

Fix found -

pip install SpeechRecognition

pip install pyaudio

If you found error -

sudo apt-get install python-pyaudio

sudo apt-get install libjack-jackd2-dev portaudio19-dev

Then again -

pip install pyaudio

To fix this issue, try to open the terminal and execute:

brew install portaudio
pip install pyaudio

I hope this works for U ;)

Mac comes with Python 2.7 pre-installed by Apple. and its default path is /usr/bin/python but if you install python 3 then it uses different path which is /applications/python 3 (depend on latest version 3.4 3.5 ..) so you have to install pyaudio and pip for python 3 separate

open the terminal and execute:

cd /Applications/Python\ 3.5 
pip3 install SpeechRecognition
pip3 install pyaudio

You need to install packadge "pyaudio"

Antonio

If you want to use audio input from microphones, PyAudio is also necessary. If not installed, the library will still work, but Microphone will not be defined.

Source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!