I am in progress of making a virtual assistant (like cortana in windows) but just after importing speechrecognition, and setting it up, it shows an error "Pyaudio not found, check installation" , or in detail, this is the whole error I am getting while I run it. :
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 108, in get_pyaudio
import pyaudio
ModuleNotFoundError: No module named 'pyaudio'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\machine_learning\raw_ai\Virtual assistant.py", line 59, in <module>
take()
File "C:\machine_learning\raw_ai\Virtual assistant.py", line 31, in take
with sr.Microphone() as source:
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 79, in __init__
self.pyaudio_module = self.get_pyaudio()
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\site-packages\speech_recognition\__init__.py", line 110, in get_pyaudio
raise AttributeError("Could not find PyAudio; check installation")
AttributeError: Could not find PyAudio; check installation
Here is my code(it runs perfectly till wish function , but when I try to speak or not even speak , it just exits the code with the error above):
import pyttsx3
import datetime
import speech_recognition as sr
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
engine.setProperty('voice', voices[0].id)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def wish():
hour = int(datetime.datetime.now().hour)
if hour >= 0 and hour <= 12:
speak("Good morning !")
elif hour > 12 and hour <= 5:
speak("Good Aftrenoon !")
else:
speak("Good night")
speak("How may I help you ?")
def take():
r = sr.Recognizer()
with sr.Microphone() as source:
print("Listening.....")
r.pause_threshold(1)
audio = r.listen(source)
try:
print("Recognisizing...")
query = r.recognize_google(audio, Language = 'en-in')
print(f"User said : {query}\n")
except Exception as e:
print("Come Again ?")
return "None"
return query
if __name__ == "__main__":
wish()
take()