Home > other >  In python, text to speech pyttsx3 problem
In python, text to speech pyttsx3 problem

Time:09-26

The import sys
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
reference at the 1st floor response:
try
 
The import pythoncom
The from win32com import client

Pythoncom. CoInitialize ()
Engine=client. Dispatch (" SAPI. SpVoice ")
Engine. The Speak (' hello world ')

This is an error, wrong a MAO

CodePudding user response:

See if your system is speech recognition component, under the control panel inside the search keyword "voice"

CodePudding user response:

Whether the system can open the control panel in speech recognition, if don't tell the system lack of this component, just go to the next, now a lot of backup system to save the ISO will remove this,

CodePudding user response:

The import pythoncom
The from win32com import client

Pythoncom. CoInitialize ()
Engine=client. Dispatch (" SAPI. SpVoice ")
Engine. The Speak (' hello world ')

Can indeed

CodePudding user response:

I this, too, is always an error in the drivername there how to do in the init bosses can you solve it

CodePudding user response:

refer to 7th floor sd4892576 response:
look at the system whether can open the control panel in speech recognition, if don't tell the system lack of this component, just go to the next, now a lot of systems in order to save the backup, ISO will remove this
on the right, is really the problem, download the speech recognition module can voice!!!!!!!!!!!!!!! Thank you very much!!!!!!!!!!!!!!!!