Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5956

How can I resolve this? - "Error with pyttsx3 on Ubuntu"

$
0
0

Description

I'm encountering an error when trying to use pyttsx3 for text-to-speech on Ubuntu. I have already installed necessary dependencies like ffmpeg and libespeak. The error points to a ReferenceError: weakly-referenced object no longer exists.

Code

Here's the code I'm using:

import pyttsx3engine = pyttsx3.init()def text_to_speech(text, gender='male', audio_file="generated_audio.mp3"):    voices = engine.getProperty('voices')    if gender == 'female':        engine.setProperty('voice', voices[1].id)  # Female voice    else:        engine.setProperty('voice', voices[0].id)  # Male voice    engine.setProperty('rate', 120)    engine.setProperty('volume', 1.0)    engine.save_to_file(text, audio_file)    engine.runAndWait()text_to_speech("Hello, this is a test.")

Error

Here is the error message:

Exception ignored on calling ctypes callback function: <bound method EspeakDriver._onSynth of <pyttsx3.drivers.espeak.EspeakDriver object at 0x789ee9d01270>>Traceback (most recent call last):  File "/home/apollo/.local/lib/python3.10/site-packages/pyttsx3/drivers/espeak.py", line 180, in _onSynth    self._proxy.notify('finished-utterance', completed=True)ReferenceError: weakly-referenced object no longer exists

Environment

  • OS: Ubuntu
  • Python version: 3.10
  • pyttsx3 version: 2.90

Steps to Reproduce

  1. Install pyttsx3 with pip install pyttsx3
  2. Run the provided code snippet.

What I've Tried

  • Ensuring ffmpeg and libespeak are installed
  • Reinstalling pyttsx3
  • Searching for similar issues, but none of the solutions worked

Additional Context

I suspect there might be some compatibility issues with the library versions or the way I'm initializing the pyttsx3 engine.

Does anyone have any insight on how to resolve this? 😟


Viewing all articles
Browse latest Browse all 5956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>