Mac Big sur 11.2.3 with python3

I have installed python3.9.
I try to build a python script for speechRecognition.

I installed
pip install SpeechRecognition
brew install audioport
pip3 install pyaudio

Then copy an paste from a copple of examples: I.G.

Code Block
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
print("Say something!")
audio = r.listen(source)

and so on.
What i get all time is an error. Most like:

Code Block
||PaMacCore (AUHAL)|| Error on line 1277: err='-66748', msg=Unknown Error
Traceback (most recent call last):
File "/Users/horst/VisualStudioCodeWork/Python_Projects/Amelie_03/SpeechRecognition.py", line 9, in <module>
with sr.Microphone() as source:
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/speech_recognition/__init__.py", line 87, in __enter__
self.stream = self.audio.open(
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyaudio.py", line 750, in open
stream = Stream(self, *args, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/pyaudio.py", line 441, in __init__
self._stream = pa.open(arguments)
OSError: [Errno -9986] Internal PortAudio error

I have googled so many time. Reinstall, and install. Follow all tips. Finally i have no idea more.

Is there anybody can help?
Thanks in advanced.

P.S. On Linux all works fine. Why not on mac?

Edit:
I found this on stackoverflow:
brew uninstall portaudio
brew install portaudio --HEAD
  • -HEAD was the solution for leav the error ((OMG)) :(

but now i get'nt signal from microphon :(
I'm very frustrated.
Now the solution.

python.py script must call from Terminal. Then big sur will give the permission choice. Finally all runs now fine also an Mac.
Thank for your attentions.
Mac Big sur 11.2.3 with python3
 
 
Q