0

When I run this code that is straight from the website

import pyttsx
engine = pyttsx.init()
engine.say('Greetings!')
engine.say('How are you today?')
engine.runAndWait()

I get this error :

Traceback (most recent call last):
  File "C:\Users\Aymen\Desktop\AI.py", line 2, in <module>
    engine = pyttsx.init()
  File "C:\Python27\lib\site-packages\pyttsx\__init__.py", line 39, in init
    eng = Engine(driverName, debug)
  File "C:\Python27\lib\site-packages\pyttsx\engine.py", line 45, in __init__
    self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
  File "C:\Python27\lib\site-packages\pyttsx\driver.py", line 66, in __init__
    self._driver = self._module.buildDriver(weakref.proxy(self))
  File "C:\Python27\lib\site-packages\pyttsx\drivers\sapi5.py", line 37, in buildDriver
    return SAPI5Driver(proxy)
  File "C:\Python27\lib\site-packages\pyttsx\drivers\sapi5.py", line 56, in __init__
    self.setProperty('voice', self.getProperty('voice'))
  File "C:\Python27\lib\site-packages\pyttsx\drivers\sapi5.py", line 87, in getProperty
    return self._tts.Voice.Id
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 466, in __getattr__
    return self._ApplyTypes_(*args)
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 459, in _ApplyTypes_
    self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221164), None)

im on windows 10 using python 2.7

Aymen
  • 1
  • 3
  • Just ran this in mint linux with zero problems. There's likely something wrong with you install of pyttsx or python. – sage88 Jun 21 '16 at 00:39

2 Answers2

1

install pywin32 then make sure that pywintypes27.dll is in the C:\Windows\System32 directory.

ppersia37
  • 52
  • 2
  • 8
0

If you are using python3 , use the pyttsx3 library instead of pyttsx.

pip install pyttsx3

It has no errors as far as i have tested.

Natesh bhat
  • 12,274
  • 10
  • 84
  • 125