6

I am working with the python module pyttsx for text to speech and when I run the code, I get this error:

     File "Practice_File.py", line 2, in <module>
     engine = pyttsx.init()
     File "/Library/Python/2.7/site-packages/pyttsx/__init__.py",
     line 39, in init
     eng = Engine(driverName, debug)
     File "/Library/Python/2.7/site-packages/pyttsx/engine.py", line
     45, in __init__
     self.proxy = driver.DriverProxy(weakref.proxy(self), driverName,
     debug)
     File "/Library/Python/2.7/site-packages/pyttsx/driver.py", line
     64, in __init__
     self._module = __import__(name, globals(), locals(), [driverName])
     File "/Library/Python/2.7/site-packages/pyttsx/drivers
     /nsss.py", line 26, in <module>
     class NSSpeechDriver(NSObject):
     objc.BadPrototypeError: Objective-C expects 1 arguments, Python
     argument has 2 arguments for <unbound selector initWithProxy of
     NSSpeechDriver at 0x107592e68>

Here is my python code:

    import pyttsx
    engine = pyttsx.init()
    engine.say('Good morning.')
    engine.runAndWait()

Any ideas on how to fix this issue? Thank you.

Ajax1234
  • 69,937
  • 8
  • 61
  • 102
  • I'm interested to know the outcome of this as i am facing similar issues. – D0cNet Jan 27 '17 at 21:51
  • 2
    I am not sure. The software for pyttsx has a bug in it, as in the python code it expects two arguments to be passed to it. I looked through the source code file for pyttsx but could not find anything. I ended up using the os python module to output a vocal version of the input. Here is the link: http://stackoverflow.com/questions/1614059/how-to-make-python-speak – Ajax1234 Jan 27 '17 at 22:23
  • Right, "from os import system system('say '+text')" worked perfectly. – D0cNet Jan 30 '17 at 01:36
  • That is great! I think it is the only way to make the computer speak as I am not sure if pyttsx is being maintained at all. – Ajax1234 Jan 30 '17 at 13:08

0 Answers0