首先是设置:Windows 8.1 64 位,Python 3.4 32 位。
我想运行代码 here .所以我安装了 comtypes
pip install comtypes
然后我尝试运行代码,我明白了
ImportError: cannot import name 'SpeechLib'
然后尝试了这段代码here尝试生成所需的 SpeechLib 模块。
但是我仍然遇到同样的错误,接下来我应该尝试什么?
请您参考如下方法:
运行这些行使其工作:
from comtypes.client import CreateObject
engine = CreateObject("SAPI.SpVoice")
stream = CreateObject("SAPI.SpFileStream")
输出是:
# Generating comtypes.gen._C866CA3A_32F7_11D2_9602_00C04F8EE628_0_5_4
# Generating comtypes.gen.SpeechLib
在这之后我没有再出现导入错误,正如预期的那样。
