The import importlib
The import pyttsx3
The import pythoncom
Pythoncom. CoInitialize ()
Importlib. Reload (sys)
Engine=pyttsx3. The init ()
Engine. Say, 'hello world')
Engine. RunAndWait ()
This code can run on another computer, have to quote the following such mistakes on my computer, can't reshipment system, great god taught, the question has bothered me for a few days,,,,
Traceback (the most recent call last) :
File "D: \ Python \ Python36 \ lib \ site - packages \ pyttsx3 \ set py", line 44, in the init
Eng=_activeEngines [driverName]
The File "D: \ Python \ Python36 \ lib \ weakref py", line 137, in the __getitem__
O=self. Data [key] ()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (the most recent call last) :
The File "D: \ Python \ Python36 \ lib \ site - packages \ win32com \ client \ dynamic py", line 89, in _GetGoodDispatch
IDispatch=pythoncom. Connect (IDispatch)
Pywintypes.com _error: (- 2147221005, 'string' invalid class, None, None)
During handling of the above exception, another exception occurred:
Traceback (the most recent call last) :
The File "& lt; Pyshell# 1 & gt;" , line 1, in
E=pyttsx3. The init ()
The File "D: \ Python \ Python36 \ lib \ site - packages \ pyttsx3 \ set py", 46, the line in the init
Eng=Engine (driverName, debug)
The File "D: \ Python \ Python36 \ lib \ site - packages \ pyttsx3 \ engine py", line 52, in __init__
The self. The proxy=driver. DriverProxy (weakref proxy (self), driverName, debug)
The File "D: \ Python \ Python36 \ lib \ site - packages \ pyttsx3 \ driver py", line 77, in __init__
Self. _driver=self. _module. BuildDriver (weakref. Proxy (self))
The File "D: \ Python \ Python36 \ lib \ site - packages \ pyttsx3 \ drivers \ sapi5 py", line 22, in buildDriver
Return SAPI5Driver (proxy)
The File "D: \ Python \ Python36 \ lib \ site - packages \ pyttsx3 \ drivers \ sapi5 py", 26, the line in __init__
Self. _tts=win32com. Client. Dispatch (' SAPI. SPVoice ')
The File "D: \ Python \ Python36 \ lib \ site - packages \ win32com \ client \ set p y", line 95, Dispatch in
Dispatch, the userName=dynamic. _GetGoodDispatchAndUserName (dispatch, userName, CLSCTX)
The File "D: \ Python \ Python36 \ lib \ site - packages \ win32com \ client \ dynamic py", line 114, in _GetGoodDispatchAndUserName
Return (_GetGoodDispatch (IDispatch, CLSCTX), userName)
The File "D: \ Python \ Python36 \ lib \ site - packages \ win32com \ client \ dynamic py", line 91, in _GetGoodDispatch
IDispatch=pythoncom. CoCreateInstance (IDispatch, None, CLSCTX, pythoncom IID_IDispatch)
Pywintypes.com _error: (- 2147221005, 'string' invalid class, None, None)
CodePudding user response:
Try
The import pythoncom
The from win32com import client
Pythoncom. CoInitialize ()
Engine=client. Dispatch (" SAPI. SpVoice ")
Engine. The Speak (' hello world ')
CodePudding user response:
Is your python version to use 32-bit I also try for a long time later into a 32 bit python can, and using 64 - bit python environment will appear this kind of problem, showed no registration, but I also don't know how to register a 64 - bit,CodePudding user response:
The