Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16595

import error of comtypes in linux whil using pyttsx3 module

$
0
0

I am having an issue in the pyttsx3 module while using it in linux(raspberrian).When I use the module it gives an error in the following line:engine = pyttsx3.init('sapi5')

the error is:

    self._module = importlib.import_module(name)  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module    return _bootstrap._gcd_import(name[level:], package, level)  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked  File "<frozen importlib._bootstrap_external>", line 790, in exec_module  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed  File "/home/indian53/.local/lib/python3.9/site-packages/pyttsx3/drivers/sapi5.py", line 1, in <module>    import comtypes.client  # Importing comtypes.client will make the gen subpackage  File "/home/indian53/.local/lib/python3.9/site-packages/comtypes/__init__.py", line 28, in <module>    from _ctypes import COMErrorImportError: cannot import name 'COMError' from '_ctypes' (/usr/lib/python3.9/lib-dynload/_ctypes.cpython-39-arm-linux-gnueabihf.so)

I also tried

pip install ctypes

but got the following error:

ERROR: Could not find a version that satisfies the requirement ctypesERROR: No matching distribution found for ctypes

edit-This is the code of the file I am working in

import pyttsx3import speech_recognition as srengine = pyttsx3.init('sapi5')voices = engine.getProperty('voices')engine.setProperty('voice', voices[0].id)def speak(audio):    engine.say(audio)    engine.runAndWait()def respond(q):    print(q)    speak(q)def takecommand(t):        r = sr.Recognizer()        with sr.Microphone() as source:            r.adjust_for_ambient_noise(source, duration=0.2)            print("listening...")            audio = r.listen(source)            print("recognizing...")        try:            global query            query = r.recognize_google(audio)            query = query.lower()            print(query)        except Exception as e:            if t == 1:                respond("Sorry, can you repeat that?")            takecommand(1)        return str(query)print("hello world")respond("happy life")q = takecommand(1)

I would appreciate if someone could help

Don't forget I am working on linux and this is working fine on windows

Please don't mark this question as duplicate because other answer didn't help


Viewing all articles
Browse latest Browse all 16595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>