Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite Looping in startLoop sapi5.py #308

Closed
MikeKadoshnikov opened this issue Mar 31, 2024 · 3 comments
Closed

Infinite Looping in startLoop sapi5.py #308

MikeKadoshnikov opened this issue Mar 31, 2024 · 3 comments

Comments

@MikeKadoshnikov
Copy link

MikeKadoshnikov commented Mar 31, 2024

Using this package in a Robotics project, we have a function for speaking below:
def say(self, text):
  self.face.set_robot_state("talking")
  if (self.voice._inLoop):
   self.voice.endLoop()
  self.voice.say(text)
  self.voice.runAndWait()
  self.face.set_robot_state("idle")

and the runAndWait() function ends up running into an infinite loop. Going through PyCharm debugging I have narrowed it down to sapi5.py where it is getting stuck in startLoop(self) and looking at the code it is not obvious how this while loop is supposed to stop. Haven"t found any resources on circumventing this issue, as its unfortunate since we wanted to use this package for our assignments, we will have to look for an alternative.
pyttsx3issue

@MikeKadoshnikov
Copy link
Author

Found a way to have it not infinite loop but it requires us to initialize pyttsx3 every time we want the robot to say something, although it works it seems somewhat resource intensive since we have to reinitialize it everytime

@willwade
Copy link
Collaborator

So Im trying to replicate this..

import pyttsx3

def say(theengine, text): 
    if (theengine._inLoop):
        theengine.endLoop()
    theengine.say(text)
    theengine.runAndWait()

engine = pyttsx3.init()
say(engine, "Hello, World!")

Have I got that right? That is not looping for me (although I am working in PR #329 - so test with that if you can just incase its me)

@MikeKadoshnikov
Copy link
Author

Unfortunately we do not have access to the exact system we tested on. Although this issue primarily showed up on a raspberry pi 4, I believe we narrowed the issue down to global initialization with threading, somehow with the threading we couldn"t reach the global engine. The solution was to initialize it every time we needed speech, and that seemed to work alright for what we needed it to do.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants