Erreur pyttsx3 : TypeError: item 1 in _argtypes_ ...
gab_iwi
-
yg_be Messages postés 23541 Date d'inscription Statut Contributeur Dernière intervention -
yg_be Messages postés 23541 Date d'inscription Statut Contributeur Dernière intervention -
Bonjour à tous,
J'essaie un script python mais il me retourne une erreur à cause de pyttsx3 alors que sur la machine d'une connaissance il fonctionne. J'ai cherché et beaucoup de gens ont la même erreur mais jamais à cause de la même chose donc je fais appel à vous.
Je vous mets mon code même si je pense que c'est logiciel (script qui fait un chat bot vocal):
import openai import speech_recognition as sr import pyttsx3 # Configurer une clé d'API valide openai.api_key = "tacleapi-xxxxxXXXX1111222abc" # Initialiser le recognizer r = sr.Recognizer() # Initialiser le moteur de synthèse vocale engine = pyttsx3.init() while True: # Ecouter pour la commande vocale with sr.Microphone() as source: print("Ecoute...") audio = r.listen(source) # Transcrire la commande vocale try: prompt = r.recognize_google(audio, language="fr-FR") print("Tu as dit: " + prompt) if prompt == "exit": break except sr.UnknownValueError: print("Je n'ai pas compris") continue except sr.RequestError as e: print("Erreur de service; {0}".format(e)) continue # Envoyer une requête à l'API de GPT response = openai.Completion.create( engine="text-davinci-003", prompt=prompt, max_tokens=2048, n=1, stop=None, temperature=0.5, ) # Afficher la réponse print(response["choices"][0]["text"]) engine.say(response["choices"][0]["text"]) engine.runAndWait()
Mon erreur :
Traceback (most recent call last):
File "C:\EduPython\App\lib\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\EduPython\App\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\EduPython\App\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
from comtypes.gen import SpeechLib # comtypes
ImportError: cannot import name 'SpeechLib' from 'comtypes.gen' (C:\EduPython\App\lib\site-packages\comtypes\gen\__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\EduPython\App\lib\ctypes\__init__.py", line 121, in WINFUNCTYPE
return _win_functype_cache[(restype, argtypes, flags)]
KeyError: (<class 'ctypes.HRESULT'>, (<class 'comtypes.automation.tagVARIANT'>, <class 'comtypes.LP_POINTER(ISpeechGrammarRule)'>), 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "F:\nsi\projet_première\chatbot_mainlibre.py", line 13, in <module>
engine = pyttsx3.init()
File "C:\EduPython\App\lib\site-packages\pyttsx3\__init__.py", line 22, in init
eng = Engine(driverName, debug)
File "C:\EduPython\App\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\EduPython\App\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
self._module = importlib.import_module(name)
File "C:\EduPython\App\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\EduPython\App\lib\site-packages\pyttsx3\drivers\sapi5.py", line 6, in <module>
engine = comtypes.client.CreateObject("SAPI.SpVoice")
File "C:\EduPython\App\lib\site-packages\comtypes\client\__init__.py", line 227, in CreateObject
return _manage(obj, clsid, interface=interface)
File "C:\EduPython\App\lib\site-packages\comtypes\client\__init__.py", line 165, in _manage
obj = GetBestInterface(obj)
File "C:\EduPython\App\lib\site-packages\comtypes\client\__init__.py", line 111, in GetBestInterface
mod = GetModule(tlib)
File "C:\EduPython\App\lib\site-packages\comtypes\client\_generate.py", line 142, in GetModule
mod = _create_wrapper_module(tlib, pathname)
File "C:\EduPython\App\lib\site-packages\comtypes\client\_generate.py", line 250, in _create_wrapper_module
mod = _my_import(fullname)
File "C:\EduPython\App\lib\site-packages\comtypes\client\_generate.py", line 36, in _my_import
return importlib.import_module(fullname)
File "C:\EduPython\App\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\EduPython\App\lib\site-packages\comtypes\gen\_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4.py", line 864, in <module>
(['out', 'retval'], POINTER(VARIANT), 'SaveStream')
File "C:\EduPython\App\lib\site-packages\comtypes\__init__.py", line 328, in __setattr__
self._make_methods(value)
File "C:\EduPython\App\lib\site-packages\comtypes\__init__.py", line 697, in _make_methods
prototype = WINFUNCTYPE(restype, *argtypes)
File "C:\EduPython\App\lib\ctypes\__init__.py", line 123, in WINFUNCTYPE
class WinFunctionType(_CFuncPtr):
TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported.
Merci d'avance pour votre aide !
A voir également:
- Erreur pyttsx3 : TypeError: item 1 in _argtypes_ ...
- Erreur 0x80070643 - Accueil - Windows
- J'aime par erreur facebook notification - Forum Facebook
- Code erreur f3500-31 ✓ - Forum Bbox Bouygues
- Java code erreur 1603 ✓ - Forum Windows
- Comment recuperer whatsapp supprimé par erreur - Guide
1 réponse
yg_be
Messages postés
23541
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 584
bonjour,
as-tu essayé en passant un argument à init()?
engine = pyttsx3.init('dummy')