Uberi / speech_recognition

Speech recognition module for Python, supporting several engines and APIs, online and offline.
https://pypi.python.org/pypi/SpeechRecognition/
BSD 3-Clause "New" or "Revised" License
8.3k stars 2.39k forks source link

Cannot use PyAudio in MacOS M1. #714

Open Nuna7 opened 9 months ago

Nuna7 commented 9 months ago

Hi, I have been trying to use SpeechRecognition module. Here is my code

` import speech_recognition as sr

def real_time_speech_recognition(): recognizer = sr.Recognizer()

with sr.Microphone() as source:
    print("Say something or press 'q' to end.")

`

However, it keep on outputting the same error :

Traceback (most recent call last): File "/Users/nuntea/Documents/Vasundhara Geo technology/Voice recognition and NER/Real Time Speech recogntiion/RTSR.py", line 11, in <module> real_time_speech_recognition() File "/Users/nuntea/Documents/Vasundhara Geo technology/Voice recognition and NER/Real Time Speech recogntiion/RTSR.py", line 7, in real_time_speech_recognition with sr.Microphone() as source: File "/Users/nuntea/Documents/Vasundhara Geo technology/Voice recognition and NER/Real Time Speech recogntiion/myenv/lib/python3.9/site-packages/speech_recognition/__init__.py", line 80, in __init__ self.pyaudio_module = self.get_pyaudio() File "/Users/nuntea/Documents/Vasundhara Geo technology/Voice recognition and NER/Real Time Speech recogntiion/myenv/lib/python3.9/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

However, I have already install PyAudio.

`(myenv) nuntea@Zonunmawias-MacBook-Air Real Time Speech recogntiion % pip list Package Version


certifi 2023.11.17 charset-normalizer 3.3.2 idna 3.4 keyboard 0.13.5 pip 23.3.1 PyAudio 0.2.14

requests 2.31.0 setuptools 69.0.0 SpeechRecognition 3.10.0 urllib3 2.1.0 wheel 0.41.3`

I have tried different method mention in stackoverflow and other resources but couldn't fixed it :

(myenv) nuntea@Zonunmawias-MacBook-Air Real Time Speech recogntiion % xcode-select --install xcode-select: error: command line tools are already installed, use "Software Update" in System Settings to install updates

(myenv) nuntea@Zonunmawias-MacBook-Air Real Time Speech recogntiion % brew install portaudio Warning: portaudio 19.7.0 is already installed and up-to-date. To reinstall 19.7.0, run: brew reinstall portaudio

(myenv) nuntea@Zonunmawias-MacBook-Air Real Time Speech recogntiion % pip3 install pyaudio Requirement already satisfied: pyaudio in ./myenv/lib/python3.9/site-packages (0.2.14)

Please help.

UninspiredCarrot commented 9 months ago

Hi @Nuna7, I came across the same issue when I first used this library on my M1 Mac too, although I installed PyAudio the way it is described in the README. Below is the part in the docs I did to fix it, let me know if the issue still continues: