Answer the question
In order to leave comments, you need to log in
How to use win32com.client from thread?
There are two codes, one works:
#!/usr/bin/python2
# -*- coding: cp1251 -*-
from win32com.client import constants
import win32com.client
sapi = win32com.client.Dispatch("SAPI.SpVoice")
phrase = "Привет, мир!"
sapi.Speak(phrase, constants.SVSFlagsAsync)
#!/usr/bin/python2
# -*- coding: cp1251 -*-
from thread import *
from win32com.client import constants
import win32com.client
def thread():
sapi = win32com.client.Dispatch("SAPI.SpVoice")
phrase = "Привет, мир!"
sapi.Speak(phrase, constants.SVSFlagsAsync)
start_new_thread(thread, ())
Answer the question
In order to leave comments, you need to log in
I can't test it right now, but in theory it should work like this:
#!/usr/bin/python2
# -*- coding: cp1251 -*-
import pythoncom
from thread import *
from win32com.client import constants
import win32com.client
def thread():
sapi = win32com.client.Dispatch("SAPI.SpVoice")
phrase = "Привет, мир!"
pythoncom.CoInitialize()
sapi.Speak(phrase, constants.SVSFlagsAsync)
pythoncom.CoUninitialize()
start_new_thread(thread, ())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question