[SOLVED] Speech recognition microphone needs PyAudio 0.2.11 or later, but I have 0.2.8
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Speech recognition microphone needs PyAudio 0.2.11 or later, but I have 0.2.8
I have been studying speech recognition in python from this article https://realpython.com/python-speech-recognition/. Before a VirtualBox update a few days ago, everything was working fine. However, I had it in a saved state, so when I went back to resume my work, Vb game me an error which was resolved by deleting the saved snapshot, and booting the VM up normally. However, I had to reinstall the python stuff, the same as before, but I am getting this error now:
Code:
programmer@dev-vm:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import speech_recognition as sr
>>> r = sr.Recognizer()
>>> mic = sr.Microphone()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/programmer/.local/lib/python3.5/site-packages/speech_recognition/__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "/home/programmer/.local/lib/python3.5/site-packages/speech_recognition/__init__.py", line 113, in get_pyaudio
raise AttributeError("PyAudio 0.2.11 or later is required (found version {})".format(pyaudio.__version__))
AttributeError: PyAudio 0.2.11 or later is required (found version 0.2.8)
>>>
I have been unable to update PyAudio to the required version for the microphone class to work. I have tried many things that I've seen on a bunch of google search results, and I forget what all I have tried at this point. After two days, I am giving up and now I seek assistance.
Both my computer and my VM are running Linux Mint Sylvia 18.3 amd64, and they're both up-to-date (at the time of this post).
Speech_Recognition is version 3.8.1
Code:
$ uname -a
Linux dev-vm 4.13.0-39-generic #44~16.04.1-Ubuntu SMP Thu Apr 5 16:43:10 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
If anyone could help me, I'd be extremely grateful. Thank you for your time.
programmer@dev-vm:~$ sudo -H pip3 install pyaudio
[sudo] password for programmer:
Requirement already satisfied (use --upgrade to upgrade): pyaudio in /usr/lib/python3/dist-packages
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
programmer@dev-vm:~$ sudo -H pip install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages (10.0.1)
programmer@dev-vm:~$
So then I tried this:
Code:
programmer@dev-vm:~$ sudo -H pip install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages (10.0.1)
programmer@dev-vm:~$ sudo -H pip3 install --upgrade pip3
Collecting pip3
Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3
You are using pip version 8.1.1, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
programmer@dev-vm:~$ sudo -H pip3 install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.1
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Successfully installed pip-10.0.1
programmer@dev-vm:~$
I also tried:
Code:
programmer@dev-vm:~$ pip install --upgrade pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Found existing installation: PyAudio 0.2.8
Cannot uninstall 'PyAudio'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
programmer@dev-vm:~$ pip3 install --upgrade pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Found existing installation: PyAudio 0.2.8
Cannot uninstall 'PyAudio'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
programmer@dev-vm:~$
And I tried:
Code:
programmer@dev-vm:~$ sudo -H pip install --upgrade pyaudio
Collecting pyaudio
Downloading https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Found existing installation: PyAudio 0.2.8
Cannot uninstall 'PyAudio'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
programmer@dev-vm:~$ sudo -H pip3 install --upgrade pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
Found existing installation: PyAudio 0.2.8
Cannot uninstall 'PyAudio'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
programmer@dev-vm:~$
Oh GNU/Linux, why can't things be at least 0.0001% as easy to install/configure/maintain as on the other two main proprietary systems?
It's fun and games with Python 2 and Python 3 co-existing. Fortunately, as time progresses, distros will move over completely to Python 3.
Anyway, as far as I am aware, the correct commands to update pip3 and then upgrade the existing pyaudio module (rather than install it from scratch, my bad) are:
programmer@dev-vm:~$ sudo -H pip3 install --upgrade pip
Requirement already up-to-date: pip in /usr/local/lib/python3.5/dist-packages (10.0.1)
programmer@dev-vm:~$ sudo -H pip3 install --upgrade pyaudio
Collecting pyaudio
Using cached https://files.pythonhosted.org/packa...-0.2.11.tar.gz
Installing collected packages: pyaudio
Found existing installation: PyAudio 0.2.8
Cannot uninstall 'PyAudio'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
programmer@dev-vm:~$
Code:
programmer@dev-vm:~$ dpkg -l "*python-pyaudio*"
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-===========================-==================-==================-============================================================
ii python-pyaudio 0.2.8-1build2 amd64 Python bindings for PortAudio v19
un python-pyaudio-doc <none> <none> (no description available)
programmer@dev-vm:~$
Thanks for your continued support. The results of those commands are:
Code:
programmer@dev-vm:~$ sudo apt-get purge python-pyaudio
[sudo] password for programmer:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
python-pyaudio*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 109 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 339711 files and directories currently installed.)
Removing python-pyaudio (0.2.8-1build2) ...
programmer@dev-vm:~$ sudo -H pip3 install pyaudio
Requirement already satisfied: pyaudio in /usr/lib/python3/dist-packages (0.2.8)
programmer@dev-vm:~$
Ok, thanks. I tried the first command, but I got this:
Code:
programmer@dev-vm:~$ sudo -H pip3 uninstall pyaudio
[sudo] password for programmer:
Cannot uninstall 'PyAudio'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
programmer@dev-vm:~$
I sincerely appreciate the time you're spending helping me.
I tried it with the python speech recognition, and it worked, so thank you very much for your help!
In the future, I don't think I will update my software as often, because it's not uncommon for updates to make things worse, rendering them counter-productive, a Microsofty characteristic. It could have been because of the saved state I left the VM in, but after that update, it took a significant chunk of my productivity time away. That seems to be a common problem in the open-source community.
But anyway, now I'm able to start researching again, so once again, thank you very much for your time and help
Just as a reference.
Developing python is tricky since many OS's use it, which can make updating tricky.
You can try using virtual environments, or maybe Anaconda and install it as a local user, which should allow you to install any versions needed without affecting the system version of python.
I tried it with the python speech recognition, and it worked, so thank you very much for your help!
In the future, I don't think I will update my software as often, because it's not uncommon for updates to make things worse, rendering them counter-productive, a Microsofty characteristic. It could have been because of the saved state I left the VM in, but after that update, it took a significant chunk of my productivity time away. That seems to be a common problem in the open-source community.
But anyway, now I'm able to start researching again, so once again, thank you very much for your time and help
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.