I am running Python 3.8.5 on Mac OS Big sur.
The issue originates from my attempt to use the python library speech_recognition.
From https://github.com/Uberi/speech_recognition, an example of code contains the following, which results in the RequestError, which is an import error.
try:
print("Sphinx thinks you said " + r.recognize_sphinx(audio, language = 'it_IT'))
except sr.UnknownValueError:
print("Sphinx could not understand audio")
except sr.RequestError as e:
print("Sphinx error; {0}".format(e))
Attempting to install the module pocketsphinx with pip, I get two large bodies of errors, but at the end of the first block there is this:
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pocketsphinx
Any search on the internet will lead to this solution (github: https://github.com/deanmalmgren/textract/issues/209, stack overflow: ERROR: Failed building wheel for pocketsphinx while trying to install pocketsphinx with pip):
sudo apt-get install -y python python-dev python-pip build-essential swig git libpulse-dev
pip install pocketsphinx
Now, it is my understanding that apt-get is not available on Mac OS X. Instead, you can use brew. But almost none of these can be installed with brew.
I tried to run:
brew install pocketsphinx
And it installed cmu-pocketsphinx, but this doesn't help me in using pocketsphinx in python.
I also tried all the instructions in the "Install development version" on https://pypi.org/project/pocketsphinx/.
I even tried modifying 2 lines of c code as per instructions here, but to no avail: https://github.com/MycroftAI/mycroft-precise/issues/75
Without pocketsphinx, it's impossible to use, among others, speech_recognition, so my question is how can you install pocketsphinx for python?