import speech_recognition as sr
import webbrowser
import pyttsx3
recognizer = sr.Recognizer() # to recognize speech
engine = pyttsx3.init() # to convert text to speech and initialize the pyttsx3 engine
def speak(text):
engine.say(text)
engine.runAndWait()
if name == “main”:
speak (“Initializing Jarvis…”)
while True:
r = sr.Recognizer()
print("Recognising")
with sr.Microphone() as source:
print("Listening...")
audio = r.listen(source, timeout = 2)
# Recognise the speech using Jarvis
try:
command = r.recognize_google(audio)
print(f"You said: {command}")
except sr.UnknownValueError:
print("Sorry, I did not understand that.")
except Exception as e:
print(f"An error occurred: {e}")
this is my code for jarvis
Could not import the PyAudio C module ‘pyaudio._portaudio’.
Traceback (most recent call last):
File “/Users/priyanka/Desktop/python/Learning/Project/.venv/lib/python3.12/site-packages/speech_recognition/init.py”, line 103, in get_pyaudio
import pyaudio
File “/Users/priyanka/Desktop/python/Learning/Project/.venv/lib/python3.12/site-packages/pyaudio/init.py”, line 111, in
import pyaudio._portaudio as pa
ImportError: dlopen(/Users/priyanka/Desktop/python/Learning/Project/.venv/lib/python3.12/site-packages/pyaudio/_portaudio.cpython-312-darwin.so, 0x0002): symbol not found in flat namespace ‘_PaMacCore_SetupChannelMap’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/Users/priyanka/Desktop/python/Learning/Project/main.py”, line 18, in
with sr.Microphone() as source:
^^^^^^^^^^^^^^^
File “/Users/priyanka/Desktop/python/Learning/Project/.venv/lib/python3.12/site-packages/speech_recognition/init.py”, line 75, in init
self.pyaudio_module = self.get_pyaudio()
^^^^^^^^^^^^^^^^^^
File “/Users/priyanka/Desktop/python/Learning/Project/.venv/lib/python3.12/site-packages/speech_recognition/init.py”, line 105, in get_pyaudio
raise AttributeError(“Could not find PyAudio; check installation”)
AttributeError: Could not find PyAudio; check installation
and this is the error I am stuck with
can anybody please help me out