You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Resources/WPy64-3720/python-3.7.2.amd64/Lib/site-packages/comtypes/test/test_sapi.py

33 lines
1.1 KiB

# http://www.microsoft.com/technet/scriptcenter/funzone/games/sapi.mspx
# ../gen/_C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_0
# http://thread.gmane.org/gmane.comp.python.ctypes.user/1485
import os, unittest, tempfile
from comtypes.client import CreateObject
class Test(unittest.TestCase):
def test(self, dynamic=False):
engine = CreateObject("SAPI.SpVoice", dynamic=dynamic)
stream = CreateObject("SAPI.SpFileStream", dynamic=dynamic)
from comtypes.gen import SpeechLib
fd, fname = tempfile.mkstemp(suffix=".wav")
os.close(fd)
stream.Open(fname, SpeechLib.SSFMCreateForWrite)
# engine.AudioStream is a propputref property
engine.AudioOutputStream = stream
self.assertEqual(engine.AudioOutputStream, stream)
engine.speak("Hello, World", 0)
stream.Close()
filesize = os.stat(fname).st_size
self.assertTrue(filesize > 100, "filesize only %d bytes" % filesize)
os.unlink(fname)
def test_dyndisp(self):
return self.test(dynamic=True)
if __name__ == "__main__":
unittest.main()