in this code for convert speech to text in python
import speech_recognition as sr
# ساخت یک شیء از کلاس Recognizer
recognizer = sr.Recognizer()
# ضبط صدا از میکروفون
with sr.Microphone() as source:
print("لطفاً گفتار خود را شروع کنید...")
audio = recognizer.listen(source)
text = recognizer.recognize_google(audio)
print(f"متن تشخیص داده شده: {text}")
i get an error: ( mac OS 14 )
Exception has occurred: AttributeError Could not find PyAudio; check installation ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/site-packages/pyaudio/_portaudio.cpython-311-darwin.so, 0x0002): symbol not found in flat namespace '_PaMacCore_SetupChannelMap'
During handling of the above exception, another exception occurred:
File "/Users/amir/Desktop/Untitled-1.py", line 6, in with sr.Microphone() as source: ^^^^^^^^^^^^^^^ AttributeError: Could not find PyAudio; check installation
but i installed pyaudio
You must install the library in the version of Python you are using
if you are using vscode you can change your python version with:
for example if you are using python3.11, you can install the library with command: