I am new to speech recognition and i am trying to use Google Speech API to build a speech to text program. I used the tutorial given in the following link and the commands within to install dependencies. TUTORIAL: https://pythonspot.com/en/speech-recognition-using-google-speech-api/
Commands:
git clone http://people.csail.mit.edu/hubert/git/pyaudio.git
cd pyaudio
sudo python setup.py install
sudo apt-get installl libportaudio-dev
sudo apt-get install python-dev
sudo apt-get install libportaudio0 libportaudio2 libportaudiocpp0 portaudio19-dev
sudo pip3 install SpeechRecognition
I then was trying to run this dummy script in spyder to see if it was working,
import speech_recognition as sr
# 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("You said: " + r.recognize_google(audio))
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))
`
Now when i run this script, i keep getting this error:
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "<ipython-input-1-2b39d94ceb5b>", line 1, in <module>
runfile('/home/sanwal092/Desktop/Python/SR/dummy.py', wdir='/home/sanwal092/Desktop/Python/SR')
File "/home/sanwal092/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "/home/sanwal092/anaconda3/lib/python3.6/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/sanwal092/Desktop/Python/SR/dummy.py", line 14, in <module>
with sr.Microphone() as source:
File "/home/sanwal092/anaconda3/lib/python3.6/site-packages/speech_recognition/__init__.py", line 78, in __init__
self.pyaudio_module = self.get_pyaudio()
File "/home/sanwal092/anaconda3/lib/python3.6/site-packages/speech_recognition/__init__.py", line 109, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
I have looked around on the internet to see if i can work my way around this but nothing i have found seems to work and this is the first time i am working with speech recognition of any sort.
Any help for this problem and any suggestions of how to learn and get better at speech recognition would be tremendously appreciated.