0

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()
Dev
  • 95
  • 10
  • try executing the program after running `pip install pyaudio`. – agupta Nov 02 '20 at 05:29
  • that doesnt work , it gives a huge error after pip install pyaudio, and for knowledge, I have python 3.8.2 – Dev Nov 02 '20 at 05:33
  • what's the error please add that to the question – agupta Nov 02 '20 at 05:34
  • 1
    Thanks for so much attention to the question, but I found my solution in another SO thread, thanks for attention and helping , (btw don't downvote the question as I have just earned the privilage to wite the comments, so pls) – Dev Nov 02 '20 at 05:39
  • 1
    You need to at least post the link to the answer you found. – OneLiner Nov 02 '20 at 05:57
  • sure : https://stackoverflow.com/questions/52283840/i-cant-install-pyaudio-on-windows-how-to-solve-error-microsoft-visual-c-14 – Dev Nov 02 '20 at 07:02

1 Answers1

1

For installing Pyaudio you have to do this

pip install pipwin
pipwin install PyAudio

This worked for me. Hope it works for you also