请教指定语音库时一直报错

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

请教指定语音库时一直报错

xiaoh43
This post has NOT been accepted by the mailing list yet.
各位好,小弟想简单的用下python的语音功能,但是在指定语音库时一直报错,请问是什么原因,代码如下:
import win32com.client
speak = win32com.client.Dispatch("SAPI.SpVoice")
for ur in speak.GetVoices():
       print ur.GetAttribute("Name")
此时反馈为:
Microsoft Sam
Microsoft Mike
Microsoft Mary
Microsoft Simplified Chinese
SampleTTSVoice

然后
speak.Voice = speak.GetVoices("Name = Microsoft Simplified Chinese").Item(0)
就会提示:
Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    speak.Voice = speak.GetVoices("Name = Microsoft Simplified Chinese").Item(0)
  File "C:\Python27\lib\site-packages\win32com\client\__init__.py", line 471, in __setattr__
    self._oleobj_.Invoke(*(args + (value,) + defArgs))
AttributeError: 'module' object has no attribute 'VARIANT'