I'm trying to make a basic speech Recognition assistant. I have Python version 3.8.16 of Collab. I have installed as well as imported 'pyaudio' as follows:
!python --version
!pip install SpeechRecognition
!pip install pyttsx3
!pip3 install pyaudio
!pip install pipwin
!pipwin install pyaudio
!conda install -c anaconda pyaudio
import speech_recognition as sr
import pyttsx3
import pyaudio
But the following error occurs in Collab. This code works fine in the local system i.e on Visual studio. But I need to run it on Collab.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-14-67c5e290f749> in <module>
9 import speech_recognition as sr
10 import pyttsx3
---> 11 import pyaudio
12
13 # Initialize recognizer class (for recognizing the speech)
ModuleNotFoundError: No module named 'pyaudio'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Here is my complete code:
r = sr.Recognizer()
try:
with sr.Microphone() as mic:
r.adjust_for_ambient_noise(mic,duration=0.1)
audio = r.listen(mic)
text = r.recognize_google(audio)
text = text.lower()
print(f"Recognized speech : {text}")
except sr.UnknownValueError:
print("Could not understand audio")
except sr.RequestError as e:
print("Could not request results; {0}".format(e))
I have run all other installation methods for 'Pyaudio' on Collab as given in the previous Stack Overflow but can't find any way to resolve it. What should I do?