I just wnat to make an app that tts(convert text to speech) text so i found Sapi voice is a good lib for this. It works well when I run the 'start_speacking' function in a thread. BUT, when I pause the speaker and wait for about 5-15 seconds I get this error below...

pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147201018), None)
  • my code

import threading
import time
import win32com.client
import pythoncom


speaker = win32com.client.Dispatch("SAPI.SpVoice")


def start_speaking():

    global speaker

    pythoncom.CoInitialize()
    speaker.Speak('hello world hello world hello world')




thread = threading.Thread(target=start_speaking)
thread.start()
time.sleep(1)
speaker.Pause()
0

There are 0 best solutions below