Thread target function isn't finishing

192 Views Asked by At

I have a thread being created at a certain point in a loop, but it won't create the thread again because the thread's target hasn't completed. I'm using pyttsx3 to do speech to text in the following function:

def speak(sentence):
    speech_engine.say(sentence)
    speech_engine.runAndWait()
    print('Done')

The print at the bottom is never run even though the engine is done speaking. Here is where I'm creating the thread:

t1 = threading.Thread(target=speak, args=(res,))
t1.start()

Does anyone know why the function isn't completing? Any help is greatly appreciated.

0

There are 0 best solutions below