2

I wanted to try out the pyttsx3 library in python 3.11.2 on MacOS Monterey v12.6.3. I followed the pyttsx3 tutorial as a starter, but am failing at the initialisation step of the engine:

Python 3.11.2 (main, Feb 16 2023, 03:15:23) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyttsx3
>>> engine = pyttsx3.init()
Segmentation fault: 11

I was tbh expecting this to just work out of the box, but maybe I need to install some dependencies or so? In the documentation linked above, it says to make sure that espeak and ffmpeg are installed, but it's under the "saving a voice to a file" part and I'm not on Linux. I tried to search for the topic on SO, but only found the same pyttsx3 tutorial instructions as in the documentation linked above (e.g. here) or old errors with other libraries such as this - since the error message isn't very specific.

I've also brew install-ed espeak and ffmpeg as stated in the github readme (although it was stated if on linux but it's all unix I guess), however libespeak1 wasn't an available formula.

Any ideas of what might be going wrong are appreciated!

nilsernst
  • 49
  • 1
  • 7
  • 1
    It looks like pyttsx3 hasn't had an update in nearly 3 years, so it may just be out of date, or it could be a Mac specific issue similar to the linked issue regarding Pygame. Do you get the same issue if you write a script and invoke pyttsx instead of trying to run it in the interactive console? BTW, it looks like the standard driver for Mac/Darwin is `nsss`, so its not (or shouldn't be) an issue related to `espeak`. – nigh_anxiety Apr 19 '23 at 04:24
  • @nigh_anxiety Yes, I get the same issue in a script. I guess I'll have another look at the pygame post then later and if that doesn't help or feels to complicated I'll look for another library. – nilsernst Apr 19 '23 at 08:38
  • 1
    So I found [this](https://stackoverflow.com/questions/12758591/python-text-to-speech-in-macintosh?noredirect=1&lq=1) post on MacOS tts using the OSX say command, and it works fine for my application since it's for private running on my Mac only. It also seems like one could use nsss directly using `from AppKit import NSSpeechSynthesizer`, but since the `say` terminal command just works I'll use this. – nilsernst Apr 19 '23 at 08:50

1 Answers1

1

the problem is not with the machine. The pyttsx3 module is old and this causes some malfunctioning. If you want to use this module, you will have to use older python version. My advice is 3.6.15 because any earlier version throws errors during installation process.

I am on macOS Monterey 12.4, and this worked just fine.