LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-04-2018, 09:42 PM   #1
Otacon 141.12
LQ Newbie
 
Registered: Oct 2017
Distribution: Debian, Linux Mint, Ubuntu, Finnix
Posts: 28

Rep: Reputation: Disabled
Question 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.
 
Old 05-04-2018, 09:56 PM   #2
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915
Have you tried installing pyaudio using pip? That should install the latest version.

Code:
sudo -H pip3 install pyaudio

Last edited by hydrurga; 05-04-2018 at 09:58 PM.
 
Old 05-04-2018, 10:34 PM   #3
Otacon 141.12
LQ Newbie
 
Registered: Oct 2017
Distribution: Debian, Linux Mint, Ubuntu, Finnix
Posts: 28

Original Poster
Rep: Reputation: Disabled
Thank you for your prompt reply.

The result of that was:
Code:
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?
 
Old 05-04-2018, 10:57 PM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915
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:

Code:
sudo -H pip3 install --upgrade pip

sudo -H pip3 install --upgrade pyaudio
Regarding the failure of the latter to work, do you have the python-pyaudio package installed?:
Code:
dpkg -l "*python-pyaudio*"
 
Old 05-05-2018, 03:25 PM   #5
Otacon 141.12
LQ Newbie
 
Registered: Oct 2017
Distribution: Debian, Linux Mint, Ubuntu, Finnix
Posts: 28

Original Poster
Rep: Reputation: Disabled
Here are the outputs from those commands:

Code:
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:~$
 
Old 05-05-2018, 03:35 PM   #6
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915
Thanks. Let's try removing the python-pyaudio package and installing the latest version from scratch through pip:

Code:
sudo apt-get purge python-pyaudio

sudo -H pip3 install pyaudio
 
Old 05-06-2018, 04:21 PM   #7
Otacon 141.12
LQ Newbie
 
Registered: Oct 2017
Distribution: Debian, Linux Mint, Ubuntu, Finnix
Posts: 28

Original Poster
Rep: Reputation: Disabled
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:~$
 
Old 05-06-2018, 04:28 PM   #8
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915
Thanks. Although we deleted the package, it left the module behind.

Let's try deleting that older (and problematic) module:

Code:
sudo -H pip3 uninstall pyaudio
Then reinstalling what should be the latest one:

Code:
sudo -H pip3 install pyaudio
 
Old 05-06-2018, 07:27 PM   #9
Otacon 141.12
LQ Newbie
 
Registered: Oct 2017
Distribution: Debian, Linux Mint, Ubuntu, Finnix
Posts: 28

Original Poster
Rep: Reputation: Disabled
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.
 
Old 05-06-2018, 07:36 PM   #10
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915
I'm just sorry I haven't solved this more quickly - it's an issue I've never come across before.

Next approach:

Code:
sudo -H pip3 --ignore-installed pyaudio
If this works, it will probably leave remnants from the distutils-installed module, so you should test pyaudio in case these cause issues.
 
1 members found this post helpful.
Old 05-07-2018, 01:30 PM   #11
Otacon 141.12
LQ Newbie
 
Registered: Oct 2017
Distribution: Debian, Linux Mint, Ubuntu, Finnix
Posts: 28

Original Poster
Rep: Reputation: Disabled
It's quite alright. It's not urgent. When I tried that command, it looks like it worked:

Code:
programmer@dev-vm:~$ sudo -H pip3 install --ignore-installed pyaudio
Collecting pyaudio
  Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
  Running setup.py install for pyaudio ... done
Successfully installed pyaudio-0.2.11
programmer@dev-vm:~$
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
 
Old 05-07-2018, 05:40 PM   #12
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 630

Rep: Reputation: 315Reputation: 315Reputation: 315Reputation: 315
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.
 
1 members found this post helpful.
Old 05-07-2018, 06:09 PM   #13
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 20 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915Reputation: 2915
Quote:
Originally Posted by Otacon 141.12 View Post
It's quite alright. It's not urgent. When I tried that command, it looks like it worked:

Code:
programmer@dev-vm:~$ sudo -H pip3 install --ignore-installed pyaudio
Collecting pyaudio
  Using cached https://files.pythonhosted.org/packages/ab/42/b4f04721c5c5bfc196ce156b3c768998ef8c0ae3654ed29ea5020c749a6b/PyAudio-0.2.11.tar.gz
Installing collected packages: pyaudio
  Running setup.py install for pyaudio ... done
Successfully installed pyaudio-0.2.11
programmer@dev-vm:~$
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
Great to hear.
 
  


Reply

Tags
attribute, error, python, recognition, speech


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Linux Speech Recognition Samael Linux - Software 4 07-15-2011 08:44 AM
microphone is not responding for sphinx (speech recognition) boidi Linux - Hardware 1 12-09-2010 07:47 AM
speech recognition! mifan Linux - Software 3 08-13-2005 08:25 PM
Help for Speech Recognition project skie_knite007 Programming 1 01-09-2005 11:44 PM
Speech Recognition software lxandrthegr8 Linux - Software 1 08-13-2003 04:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration