Home > Software engineering >  getting unexpected error while executing the code (with sr.Microphone() as source:)
getting unexpected error while executing the code (with sr.Microphone() as source:)

Time:04-04

image of the error I am making an Ai personal assistant on my laptop but i am getting this error. I am using python version 3.10.4 and still i am getting this print error. I am getting error in the line with sr.Microphone() as source(): due to which even the microphone icon in the taskbar is not coming plz do help to resolve it. thanks.

i have installed pyaudio file from google this is the link which i have clicked from this site plz tell how to resolve this.

error coming while upgrading pip to the latest version ----

C:\Users\DELL>pip install --upgrade pyaudio Requirement already satisfied: pyaudio in c:\users\dell\appdata\local\programs\python\python310\lib\site-packages (0.2.4) Collecting pyaudio Using cached PyAudio-0.2.11.tar.gz (37 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: pyaudio Building wheel for pyaudio (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [9 lines of output] running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-3.10 copying src\pyaudio.py -> build\lib.win-amd64-3.10 running build_ext building '_portaudio' extension error: Microsoft Visual C 14.0 or greater is required. Get it with "Microsoft C Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pyaudio Running setup.py clean for pyaudio Failed to build pyaudio Installing collected packages: pyaudio Attempting uninstall: pyaudio Found existing installation: PyAudio 0.2.4 ERROR: Cannot uninstall 'PyAudio'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

error

CodePudding user response:

In Python 2.xx, you can call print without parenthesis but in Python 3.xx, you need to call print with parenthesis. It seems like the version of pyaudio you are using is on Python 2.xx because the print statement where you are getting the error is missing parenthesis. Can you check your version of pyaudio? The latest version seems to be 0.2.11.

CodePudding user response:

According to the error you are getting, you have not entered the other parenthesis at the end of the sentence. So try entering the missing parenthesis there. If that doesn't work, try making another function like

def prn(text):
    print(text)

And then calling that function instead of the print function there.

  • Related