I try to use speech synthesis in Python 3.9.13 [MSC v.1929 64 bit (AMD64)].
If I understand well, pyttxs3
is the dedicated module (thank you in advance for any possible alternative!), which I installed successfully:
c:\>pip install -U pyttsx3
Requirement already satisfied: pyttsx3 in c:\users\...\python39\site-packages (2.90)
Requirement already satisfied: comtypes in c:\users\...\python39\site-packages (from pyttsx3) (1.1.11)
Requirement already satisfied: pywin32 in c:\users\...\python39\site-packages (from pyttsx3) (304)
Requirement already satisfied: pypiwin32 in c:\users\...\python39\site-packages (from pyttsx3) (223)
but I cannot initialize the engine: when I do
>>> e = pyttsx3.init()
Traceback (most recent call last):
File "C:\Users\...\Python39\site-packages\pyttsx3\__init__.py", line 20, in init
eng = _activeEngines[driverName]
File "C:\Program Files\...\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
...
File "C:\Users\...\Python39\site-packages\pyttsx3\drivers\sapi5.py", line 10, in <module>
import pythoncom
File "C:\Users\...\Python39\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
ModuleNotFoundError: No module named 'pywintypes'
I noticed that part of the scripts are in my Users\...\AppData\Local\Packages\PythonSoftwareFoundation...
and some are in "C:\Program Files\WindowsApps\PythonSoftwareFoundation...
. I wonder whether that might be the reason for the errors.
How could I fix this? (I also found that there are other modules, speech
and pyttsx
, which however appear to be for Python 2.7: they produce Syntax error: print "..." - did you mean print("...")?
Is there a Python 3 version of speech
or any other alternative?)
pyttxs3 is a little (actually very) glitched for example after i removed a part of my code which involved speaking something it still spoke my old code i removed the whole pyttxs3 from my code it still didn't work at last i had to uninstall the package. I used this function. You need to install pygame (it is a game making package but we will use it) and gtts i.e google text to speech