When I use the code:
speak = win32com.client.Dispatch('Sapi.SpVoice')
speak.Volume = 100
speak.Rate = 6
speak.Voice = speak.GetVoices('Name=Microsoft Mary').Item(0)
It gives me the error:
speak.Voice = speak.GetVoices('Name=Microsoft Mary').Item(0)
File "C:\Python25\lib\site-packages\win32com\gen_py\C866CA3A-32F7-11D2-9602-00C04F8EE628x0x5x4.py", line 1872, in Item
ret = self._oleobj_.InvokeTypes(0, LCID, 1, (9, 0), ((3, 1),),Index
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147200967), None)
Can someone please help? Thank you!
My Windows 10 system has no "Microsoft Mary" - only David and Zira.
You can inspect what's available with:
>>> speak.GetVoices().Item(0).GetDescription()
u'Microsoft David Desktop - English (United States)'
>>> speak.GetVoices().Item(1).GetDescription()
u'Microsoft Zira Desktop - English (United States)'
>>> speak.GetVoices().Item(2).GetDescription()
If I use one of those it works:
>>> speak.GetVoices("Name=Microsoft Zira")
<COMObject <unknown>>