I am making a voice assistant in Python. I just create its first function but I am having same traceback error again and again. can anyone tell me what mistake I am making here?
this is what i created yet:
import pyttsx3
import speech_recognition
import pyaudio
engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
# print(voices)
engine.setProperty('voice', voices[0].id)
engine.setProperty('rate', 170)
def speak(audio):
engine.say(audio)
engine.runAndWait()
def takecommand():
r = speech_recognition.Recognizer()
with speech_recognition.Microphone() as source:
print("listening")
r.pause_threshold = 1
r.energy_threshold = 300
audio = r.listen(source, 0, 4)
try:
print("understanding")
query = r.recognize_google_cloud(audio, language="en-pk")
print(f"u said{query}n")
except Exception as e:
print("say that again")
return "none"
return query
if __name__ == "__main__":
while True:
query = takecommand().lower()
if "wake up" in query:
from greetme import greetMe
greetMe()
while True:
query = takecommand().lower()
if "go to sleep" in query:
speak("Ok sir, you can call me anytime")
break
but I
Traceback (most recent call last):
File "C:UsersoneanPycharmProjectsjarvismain.py", line 36, in <module>
query = takecommand().lower()
^^^^^^^^^^^^^
File "C:UsersoneanPycharmProjectsjarvismain.py", line 19, in takecommand
with speech_recognition.Microphone() as source:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:UsersoneanPycharmProjectspythonProject1venvLibsite-packagesspeech_recognition__init__.py", line 80, in __init__
self.pyaudio_module = self.get_pyaudio()
^^^^^^^^^^^^^^^^^^
File "C:UsersoneanPycharmProjectspythonProject1venvLibsite-packagesspeech_recognition__init__.py", line 111, in get_pyaudio
from distutils.version import LooseVersion
ModuleNotFoundError: No module named 'distutils'
i am having this error again and again I couldn’t find any error in my code. i am learning python so i don’t have that much knowledge about this error
Try input this command:
pip install setuptools distutils-pytest